2010-10-10 23 views
0

我有commandLinkactionListener,它調用一個方法來更改text的值。同樣的commandLink有一個action重新加載頁面。當我點擊commandLink時,actionListener被調用。但action只完成 - 顯示更新的文本值 - 當我刷新瀏覽器。爲什麼不是outputText被自動更新?在調用操作後頁面不會刷新

一些代碼: home.jspx

(...) 
<f:view> 
<table id="main_table"> 
<tr><td width="160px"><jsp:directive.include file="./logo.jspx" /></td> 
     <td><jsp:directive.include file="./header.jspx" /></td></tr> 
<tr><td width="160px"><jsp:directive.include file="./vertical_navigation.jspx" /></td> 
     <td align="center"><ice:outputText value="main" /></ice:outputText></td></tr> 
</table> 
</f:view> 
(...) 

customer.jspx是一樣的,但outputText的值是#{customer.text} vertical_navigation.jspx:像下面的很多命令鏈接:

(...) 
<ice:form id="nav_form"><ice:panelGrid columns="1"> 
    <ice:panelCollapsible expanded="true"> 
    <f:facet name="header"><ice:panelGroup> 
     <ice:outputText value="Customer" /> 
    </ice:panelGroup></f:facet> 
    <ice:panelGrid columns="1"> 
     <ice:commandLink actionListener="#{client.defineText}" 
     immediate="true" action="customer" id="list"> 
     <ice:outputText value="List" /> 
     </ice:commandLink> 
(...) 

the bean:

(...) 
public String text; 
public void defineText(ActionEvent evt) { 
text = ... some text related to the link 
} 
public String getText() { 
return text; 
} 

好了,一切工作正常,但我必須刷新頁面,當我點擊一個鏈接,這樣的text值被更新。我在bean方法內部放置了一些System.out.println() satatements,並注意到只要點擊一個鏈接就會調用defineText方法。但是getText僅在刷新後才被調用。輸出是這樣的:

// click the link "list" 
called defineText for link list 
// click the link "new" 
called defineText for link new 
// click the link "external" 
called defineText for link external 
// refresh the broswer 
called getText // this will show the updated value of "text" for the link "external" 
// click the link "new" 
// refresh the broswer 
called defineText for link new 
called getText // this will show the updated value of "text" for the link "new" 

我與JSF 1.2ICEfaces的1.8.2工作。

回答

1

我終於找到了一種溶劑。我刪除了JSF 1.2 Apache Myfaces並由Sun RI jar取代。如果有人能解釋它爲什麼起作用,我會感激。

0

我不使用IceFaces,但嘗試從您的命令鏈接中刪除immediate="true" - 使用標準h:commandLink它可能會導致此問題。

+0

我已經嘗試過。調用getText方法(頁面刷新,很好),但不再調用defineText方法,這意味着actionListener不起作用 - 不好。 :-( – 2010-10-10 18:04:43

0

它關於週期以及如何處理事件。

從我的經驗,兩種方法來解決這個問題:

1)排隊的事件(檢查不同類型的事件),直到它的時間來更新值。

2)通過陷印與另一個標籤變通