tags:

views:

29

answers:

2

hi,

I am trying to creating a small wizard using jsf1.2 sun RI +richfaces. The user sets input data in multiple pages and in the end presses finish upon which the data is inserted in database. The info is displayed as a row in a table with edit button. when edit is clicked the data is populated in all the pages and user can edit and save it again. Also while navigating back and forth the data must be persisted in the forms. Currently i have implemented this by using multiple session scope beans that access each other's data by looking its reference in session map and some are injected as dependencies.

i would like to know if there's a standard way / good pattern of doing this by avoiding multiple session scope beans and doing lookups in session map?

if someone could throw a link to any blog/tutorial with similar example that would be great many thanks

+1  A: 

You can just make them properties of a single session scoped bean.

public class Wizard {
    private Step1 step1 = new Step1();
    private Step2 step2 = new Step2();
    private Step3 step3 = new Step3();
    // ...
}

and use it as follows

<h:form id="step1">
    <h:inputText id="input1" value="#{wizard.step1.input1}" />
    <h:inputText id="input2" value="#{wizard.step1.input2}" />
</h:form>

...

<h:form id="step2">
    <h:inputText id="input1" value="#{wizard.step2.input1}" />
    <h:inputText id="input2" value="#{wizard.step2.input2}" />
</h:form>

...

This way you just have instant access to everything from inside the action methods.

BalusC
+1  A: 

I would recommend to you to download an open source with components for JSF like PrimeFaces. It will make it much easier for you. They also have a wizard: PrimeFaces Wizard

Odelya