У меня есть 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
. Я поместил несколько System.out.println()
насыщений в методы bean-компонента и заметил, что метод 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 .