我有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