2010-10-10 64 views
0

我有commandLinkactionListener,它调用一个方法来更改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.2ICEfaces的1.8.2工作。

回答

1

我终于找到了一种溶剂。我删除了JSF 1.2 Apache Myfaces并由Sun RI jar取代。如果有人能解释它为什么起作用,我会感激。

0

我不使用IceFaces,但尝试从您的命令链接中删除immediate="true" - 使用标准h:commandLink它可能会导致此问题。

+0

我已经尝试过。调用getText方法(页面刷新,很好),但不再调用defineText方法,这意味着actionListener不起作用 - 不好。 :-( – 2010-10-10 18:04:43

0

它关于周期以及如何处理事件。

从我的经验,两种方法来解决这个问题:

1)排队的事件(检查不同类型的事件),直到它的时间来更新值。

2)通过陷印与另一个标签变通

相关问题