我有commandLink
和actionListener
,它調用一個方法來更改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.2和ICEfaces的1.8.2工作。
我已經嘗試過。調用getText方法(頁面刷新,很好),但不再調用defineText方法,這意味着actionListener不起作用 - 不好。 :-( – 2010-10-10 18:04:43