【发布时间】:2011-04-23 11:45:25
【问题描述】:
我有一个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>
(...)
豆子:
(...)
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。
【问题讨论】:
标签: java web-applications jsf icefaces