【发布时间】:2011-09-09 12:36:49
【问题描述】:
我有以下一段代码,其中包含一个简单的 h:outputText 指向一个 int 和一个 p:commandLink 来设置一个值:
<h:form id="f1">
<h:outputText id="text" value="#{testBean.index}"/>
<p:commandLink actionListener="#{testBean.test}" update="text">
<f:setPropertyActionListener target="#{testBean.index}" value="5" />
<h:graphicImage url="/images.png"/>
</p:commandLink>
</h:form>
托管 bean 如下所示:
@javax.faces.bean.ManagedBean @ViewScoped
public class TestBean implements Serializable{
private int index; // getter/setter
@PostConstruct public void init() {
index = 0;log.log(Level.WARNING, "@PostConstruct");}
public void test(ActionEvent ae){
log.log(Level.WARNING, "Index: "+index);}
}
bean 构造正确,第一次单击图像后h:ouputText 更新为5。但在我的日志消息中,我只在第一次点击图片时看到Index: 0。
类似于 Jsf updates model value with old value,但我有 JSF @ManagedBean 注释。
【问题讨论】:
标签: java google-app-engine jsf primefaces