• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

A multi-step wizard form with multiple <ui:include>s

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Saloon Keeper
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Srinivas Bonala
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic