【发布时间】:2014-02-19 10:41:24
【问题描述】:
<h:form prependId="false" id="vt_sel_form">
<p:panelGrid styleClass="center" columns="2">
<p:commandButton value="GO" oncomplete="alert(#{test.i})" actionListener="#{test.testfxn()}" update="@this"/>
</p:panelGrid>
</h:form>
import java.io.Serializable;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
@ViewScoped
@ManagedBean(name = "test")
public class TestClass implements Serializable {
int i ;
public int getI() {
return i;
}
public void setI(int i) {
this.i = i;
}
public void testfxn() {
setI(i++);
//i=i+10;
System.out.println("i" + i);
}
}
在这里,alert(#{test.i}) 始终显示 0。当我单击命令按钮时,我如何获得改变的支持 bean 值。 当我点击两次按钮时它工作正常。当我使用 a4j:commandButton 时它工作正常。
【问题讨论】:
标签: jsf-2 primefaces richfaces