问题描述
我有一个commandLink
和一个actionListener
,该actionListener
调用一种方法来更改text
的值.相同的commandLink
具有action
来重新加载页面.当我单击commandLink
时,将调用actionListener
.但是,当我刷新浏览器时,仅action
已完成-显示文本的更新值.为什么outputText
没有自动更新?
I have commandLink
with an actionListener
that calls a method to change the value of text
. The same commandLink
has an action
that reloads the page. When I click the commandLink
, the actionListener
is called. But the action
only is completed --showing the updated value of text-- when I refresh the browser. Why isn't the outputText
being automatically updated?
一些代码: 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 :许多命令链接如下:
customer.jspx is the same, but the value of the outputText
is #{customer.text}
vertical_navigation.jspx: many command links like the following:
(...)
<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()
内容,并注意到,只要单击链接,就会调用defineText
方法.但是getText
仅在刷新后才被调用.输出是这样的:
Well, everything works fine, except that I have to refresh the page when I click a link so that the value of text
is updated. I put some System.out.println()
satatements inside the bean methods and noticed that the defineText
method is called whenever I click a link. But the getText
is called only after a refresh. The output is like this:
// 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 .
推荐答案
我终于找到了解决方法.我删除了JSF 1.2 Apache Myfaces,取而代之的是Sun RI jar.如果有人能解释它为什么起作用,我将不胜感激.
I have finally found a sollution. I removed the JSF 1.2 Apache Myfaces and substituted by the Sun RI jars. If anyone can explain why it worked, I'll appreciate.
这篇关于调用动作后页面没有刷新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!