http://java.net/jira/browse/JAVASERVERFACES-1492
and related JSF specification issue:
http://java.net/jira/browse/JAVASERVERFACES_SPEC_PUBLIC-787
There are perfect resources from BalusC where these issues are described in great details:
http://balusc.blogspot.com/2011/09/communication-in-jsf-20.html#ViewScopedFailsInTagHandlers
http://balusc.blogspot.com/2010/06/benefits-and-pitfalls-of-viewscoped.html#HeyTheresPitfallsInTheTitle
This should be fixed in JSF 2.2.
However, with MyFaces 2.1.7, there is even more.
Given a simple bean:
@ManagedBean
@ViewScoped
public class Bean implements Serializable {
@PostConstruct
public void pc() {
System.out.println("in postConstruct");
}
}
and a simple form:
<h:form>
<h:commandLink value="update">
<f:ajax render="label"/>
</h:commandLink>
<h:outputText id="label" value="#{bean}"/>
</h:form>
Hitting "update" will make "label" change:
com.denisk.test.Bean@5b62a166
com.denisk.test.Bean@27afca98
com.denisk.test.Bean@3a93ea5f
It shouldn't, because the bean is ViewScoped.
PostContruct method is called only once though. This makes it even stranger...
It works fine in Mojarra 2.1.8.
I have fired a defect:
https://issues.apache.org/jira/browse/MYFACES-3558
No comments:
Post a Comment