I have a though issue with JSF 2. I use Mojarra 2.1.14 with Primefaces 3.1.4
I have a page with 2 forms : formA and formB. The two forms contains each the ViewState in an hidden input field.
<h:form id="formA" binding="#{sessionBean.formA}">
<h:commandButton value="formA" action="#{sessionBean.actionA}">
<f:ajax/>
</h:commandButton>
</h:form>
<h:form id="formB" binding="#{sessionBean.formB}">
<h:commandButton value="formB" action="#{sessionBean.actionB}">
<f:ajax/>
</h:commandButton>
</h:form>
User submits formA with an Ajax action. Inside the Java action I update explicitly formA and formB (which are binded).
public void actionA(){
FacesContext.getCurrentInstance().getPartialViewContext().getRenderIds().add(formA.getClientId());
FacesContext.getCurrentInstance().getPartialViewContext().getRenderIds().add(formB.getClientId());
System.out.println("action A!!");
}
public void actionB(){
System.out.println("action B!!");
}
In the Ajax responses there is the HTML code for formA and formB ( element) and the ViewState.
JSF updates the HTML of formA and formB and set the ViewState of the calling form : formA. formB do not contains any ViewState.
User submit formB with an Ajax action. Because ViewState is not defined, postBack is false and the renderResponse is set to true in the RESTORE phase, skipping the INVOKE APPLICATION phase: the action is not called. After the response VIEW_STATE is updated and if user sumbit formB, the action is called.
Is it a JSF 2 bug or limitation? Or Do I do something wrong ?
You can find a maven projet on GitHub: https://github.com/nithril/jsf-multiple-form
Thanks in advance for your help!
render=":formB"
insidef:ajax
tag. – partlov