Q: A multi-step wizard form with multiple <ui:include>s and one request scoped bean, how to proceed to next step?
We are working with
JSF 2.0. Actually, we are migrating from JSF 1.2 to JSF 2.0.
I have a form on `mainPage.xhtml` wherein we include 3 forms by `<ui:include>` tag.
The `
mainPage.xhtml` page look like below,
<c:if test="#{myManagedBean.stepRender eq 'firstPage'}">
<ui:include src="/public/firstPage.xhtml"/>
</c:if>
<c:if test="#{myManagedBean.stepRender eq 'secondPage'}">
<ui:include src="/public/secondPage.xhtml"/>
</c:if>
<c:if test="#{myManagedBean.stepRender eq 'thirdPage'}">
<ui:include src="/public/thirdPage.xhtml"/>
</c:if>
The `firstPage.xhtml` has a few input fields and one `<h:commandButton>` with `action="myManagedBean.continueStepOne"`.
The `secondPage.xhtml` has a few input fields and one `<h:commandButton>` with `action="myManagedBean.continueStepTwo"`.
The `thirdPage.xhtml` has also a few input fields and one `<h:commandButton>` with `action="myManagedBean.continueStepThree"`.
I used only one bean for all included pages and `mainPage.xhtml` page. The bean is request scoped.
The code of the bean class
public
String continueStepOneAction(){
== validation logic ==
stepRender="secondPage";
return "mainPage";
}
public String continueStepTwoAction(){
== validation logic ==
stepRender="thirdPage";
return "mainPage";
}
Initially when I send a request to `mainPage.xhtml`, depending on the `stepRender` value, it will include a particular page which is initially `firstPage.xhtml`.
If we enter data and click on commandbutton, then it will call `continueStepOne` action. When validations are successful, then `stepRender` value is changed. If it equals to `secondPage`, then `secondPage.xhtml` page will be included. And so on for the `thirdPage`.
The problem is, from `firstPage` to `secondPage` the method call and navigation are working properly, but in `secondPage`, when we click on the command button, then it will call only the constructor of `myManagedBean` and but it is not calling the `continueStepThreeAction()` method in the bean. then it will navigating to `firstPage.xhtml`.
my question is, Why is the continueStepThreeAction() method is not calling? can you explain me why this is happening?
and this functionality was worked in JSF1.2, but in JSF2.0 it is not working. am not able to understand where is the problem is. How can I solve it?