问题
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?
Some code: 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 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>
(...)
the bean:
(...)
public String text;
public void defineText(ActionEvent evt) {
text = ... some text related to the link
}
public String getText() {
return text;
}
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"
I'm working with JSF 1.2 and IceFaces 1.8.2.
回答1:
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.
回答2:
I don't work with IceFaces, but try to remove immediate="true"
from your command link - with standard h:commandLink
it could cause the problem.
回答3:
Its about the cycle and how the events are handled.
from my experience, two ways to fix it:
1) queue the event (check the different type of events) until its time to update the values.
2) work around by trapping with another tag
来源:https://stackoverflow.com/questions/3900925/page-does-not-refresh-after-an-action-is-called