2014-01-17 24 views
0

排序一個奇怪的問題,我不想放棄代碼如果可能的話,所以我會盡我所能解釋發生了什麼。p:commandButton更新 - 改變頁面上的「視點」?

基本上,我有一個commandButton執行AJAX操作,然後更新它所在的整個窗體。

這種形式就像這樣:

<h:form id="tabform"> 

    ..... 

    <p:commandButton update=":tabform" value="Save" ajax="true" onstart="savingDialog.show();" onsuccess="savingDialog.hide();" actionListener="#{bean.saveContent}" /> <!-- styling makes it fixed position --> 


    ..... 

    <p:editor id="ed1" /> 
    <p:editor id="ed2" /> 
    <p:editor id="ed3" /> 
    <p:editor id="ed4" /> 
    <p:editor id="ed5" /> 
    <p:editor id="ed6" /> 


</h:form> 

當我點擊保存按鈕,和我在喜歡的編輯器5,它會保存,然後將我的編輯器2.不集中的中間,但「瀏覽器視圖的焦點」(如果這是有道理的話)。

我可以確認它與commandButton上的更新有關。它在更新後似乎讓我在表格中間的一半。

有沒有解決這個問題的方法?

回答

2

使用RequestContext上的scrollTo方法在任何服務器端操作後滾動到特定組件。顯然這將需要你設計一個方案來事先知道你想要將頁面平整的組件。沒有有意義的代碼,你可以從下面開始:

public void saveContent(){ 
    //your implementation here 
    RequestContext context = RequestContext.getCurrentInstance(); 
    context.scrollTo("tabForm:ed5") 

} 
+0

這不是我正在尋找的(基於我目前的設計),但我能夠使用這個答案來幫助我的數字出一種方法來推動當前滾動,然後重新分配窗口滾動完成。 – user2124871