I have the following piece of code with a simple h:outputText
pointing to a int
and a p:commandLink
to set a value:
<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>
The managed bean looks like this:
@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);}
}
The bean is constructed correctly, and after the first click on the image the h:ouputText
is updated to 5. But in my log message I only see Index: 0
during the first click on the image.
It's something similar like Jsf updates model value with old value, but I have the JSF @ManagedBean
annotation.