wood burning stoves 2.0*
The moose likes JSF and the fly likes A multi-step wizard form with multiple <ui:include>s Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "A multi-step wizard form with multiple &lt;ui:include&gt;s" Watch "A multi-step wizard form with multiple &lt;ui:include&gt;s" New topic
Author

A multi-step wizard form with multiple &lt;ui:include&gt;s

Srinivas Bonala
Greenhorn

Joined: Feb 14, 2012
Posts: 15
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?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16012
    
  19

Welcome to the JavaRanch, Srinivas!

We have a useful message editing button labelled "Code". It generates tags that can be used to make preformatted code and XML more readable.

First of all, Don't use JSTL. It doesn't work very well with JSF. JSF has its own functions that do the job better.

The other thing that beginners often learn to their sorrow is that Request scope is not as useful in JSF as it is in other frameworks. Often you can fix problems just by using Session scope.


Customer surveys are for companies who didn't pay proper attention to begin with.
Srinivas Bonala
Greenhorn

Joined: Feb 14, 2012
Posts: 15
thanks you Tim,

We are used request scope for the bean, for request scoped bean my functionality was worked properly in JSF1.2, why this is not working with JSF2.0 version.
can you explain me why this deference is happen between JSF1.2 and JSF2.0?

and also tell me, is there any other possibility to work my functionality with request scoped beans in JSF2.0?

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16012
    
  19

Request scope behavior has not changed between JSF1 and JSF2. I can't guarantee as much for JSTL, though. As I said, JSTL doesn't work reliably in JSF.
Srinivas Bonala
Greenhorn

Joined: Feb 14, 2012
Posts: 15
thanks you Tim,

as you said, i removed JSTL tag libraries and tried with <ui:fragment> and i also tried with <h:panelGroup>. But the problem is still reproducing. i did not find the solution. Can you give me any other solution to resolve my problem, except from session scope. give me replay

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16012
    
  19

Any data you place in Request scope is effectively lost the instant that the page is rendered. The only way to retain that data is to use a scope that can span requests: View scope, Session scope, or Application scope.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: A multi-step wizard form with multiple &lt;ui:include&gt;s