You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by arnaud gonzales <ar...@gmail.com> on 2005/11/08 21:48:44 UTC

using a lookupDispatchAction to implement a WIZARD Form

Hello
I try to use a lookupDispatchAction to implement a WIZARD FORM as it is
wrote in the Struts cookbook and there is some things i still don't
understand:
Context:
<action path="/ViewStep1"
name="CreateAccesForm"
scope="session"
validate="false"
type="org.apache.struts.actions.ForwardAction"
parameter=".portail.acces.societe"/>

<action path="/ProcessStep1"
name="CreateAccesForm"
scope="session"
validate="true"
type="com.studiocanal.extranetPortail.fo.acces.actions.DemAccesAction"
input=".portail.acces.societe"
parameter="method">
<forward name="next" path="/ViewStep2.do"/>
<forward name="fail" path="/ViewStep1.do"/>
</action>

I have a List of DTO in my ActionForm ("CreateAccesForm") and others simple
properties;
i do some business in an action(ProcessStep1.do method="Verif" ) to set my
form properties with the values coming from the DB. When i finally return
mapping.findForward("fail") which call the ViewStep1.do forwardAction to
bring me back to the same jsp, my input form.
So, my jsp page ".portail.acces.societe" only display the values of my List
form properties and the others have disappear!


But if i use a forward path directly to my jsp, like that :

<forward name="fail" path=".portail.acces.societe"/>
I can find the real values of my form properties set in the html form.

So my question is why the org.apache.struts.actions.ForwardAction resets my
form simple properties according to what it find in the request, i imagine,
and does not to the DTO List properties ??

Finally, what is the goal the ViewStep1 action, ViewStep2 and so on ?

Thanks in advance

Struts config for the wizard:
<!-- Wizard Creation mappings -->

<action path="/ViewStep1"
name="CreateAccesForm"
scope="session"
validate="false"
type="org.apache.struts.actions.ForwardAction"
parameter=".portail.acces.societe"/>

<action path="/ProcessStep1"
name="CreateAccesForm"
scope="session"
validate="true"
type="com.studiocanal.extranetPortail.fo.acces.actions.DemAccesAction"
input=".portail.acces.societe"
parameter="method">
<forward name="next" path="/ViewStep2.do"/>
<forward name="fail" path=".portail.acces.societe"/>
</action>

<!-- Step 2: Compte -->
<action path="/ViewStep2"
name="CreateAccesForm"
scope="session"
type="org.apache.struts.actions.ForwardAction"
validate="false"
input=".portail.acces.compte"
parameter=".portail.acces.compte"/>

<action path="/ProcessStep2"
name="CreateAccesForm"
scope="session"
type="com.studiocanal.extranetPortail.fo.acces.actions.DemAccesAction"
parameter="method" validate="false">
<forward name="previous" path="/ViewStep1.do"/>
<forward name="next" path="/ViewStep3.do"/>
</action>

<!-- Step 3: Droits -->
<action path="/ViewStep3"
name="CreateAccesForm"
scope="session"
type="org.apache.struts.actions.ForwardAction"
input=".portail.acces.droits"
validate="false"
parameter=".portail.acces.droits"/>

<action path="/ProcessStep3"
name="CreateAccesForm"
scope="session"
type="com.studiocanal.extranetPortail.fo.acces.actions.DemAccesAction"
parameter="method">
<forward name="previous" path="/ViewStep2.do"/>
<forward name="finish" path="/wizard_done.jsp"/>
</action>

--
Cordialement,
Arnaud Gonzales.

Re: using a lookupDispatchAction to implement a WIZARD Form

Posted by Michael Jouravlev <jm...@gmail.com>.
On 11/8/05, arnaud gonzales <ar...@gmail.com> wrote:
> Hello
> I try to use a lookupDispatchAction to implement a WIZARD FORM as it is
> wrote in the Struts cookbook and there is some things i still don't
> understand:
> Context:
> <action path="/ViewStep1"
> name="CreateAccesForm"
> scope="session"
> validate="false"
> type="org.apache.struts.actions.ForwardAction"
> parameter=".portail.acces.societe"/>
>
> <action path="/ProcessStep1"
> name="CreateAccesForm"
> scope="session"
> validate="true"
> type="com.studiocanal.extranetPortail.fo.acces.actions.DemAccesAction"
> input=".portail.acces.societe"
> parameter="method">
> <forward name="next" path="/ViewStep2.do"/>
> <forward name="fail" path="/ViewStep1.do"/>
> </action>
>
> I have a List of DTO in my ActionForm ("CreateAccesForm") and others simple
> properties;
> i do some business in an action(ProcessStep1.do method="Verif" ) to set my
> form properties with the values coming from the DB. When i finally return
> mapping.findForward("fail") which call the ViewStep1.do forwardAction to
> bring me back to the same jsp, my input form.
> So, my jsp page ".portail.acces.societe" only display the values of my List
> form properties and the others have disappear!
>
>
> But if i use a forward path directly to my jsp, like that :
>
> <forward name="fail" path=".portail.acces.societe"/>
> I can find the real values of my form properties set in the html form.
>
> So my question is why the org.apache.struts.actions.ForwardAction resets my
> form simple properties according to what it find in the request, i imagine,
> and does not to the DTO List properties ??

Because when request comes in, Struts populates ActionForm fields from
request. When you do "forward", this is the same as incoming request
for Struts. And since it is an in-server forward, the request still
contains old data.

Why would not you try something more robust for your wizard:
http://struts.sourceforge.net/strutsdialogs/wizardaction.html

Here are two online demos, very similar. The first is a login/signup
action/wizard:
http://www.superinterface.com/wizard/signupWizard.do

The second is just a signup wizard with a security question:
http://www.superinterface.com/strutsdialog/wizardaction.do

Notice, that for all wizard pages the address in the browser is the
same, so you cannot go back to a stale page. Navigation is performed
on server, browser sees only the page that corresponds to current
wizard state.

--
Struts Dialogs: code-behind for Struts
http://struts.sourceforge.net/strutsdialogs

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org