You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Dan Allen <da...@mojavelinux.com> on 2003/04/06 10:52:02 UTC

multipage form struts example

Correct me if I am wrong, but if you are doing a multipage form you
have to put the form into the session scope in order to retain it
throughout the duration of the wizard, am I right?  The only way to
avoid it would be to place hidden fields in the second and third
pages to hold the values so they continue to get passed along which
would be ridiculous.

The reason I bring this up because the following snippet shows up in
the validator example that ships with struts:

<!-- Multi-Part Registration Action -->
<action    path="/multiRegistration"
           type="org.apache.struts.webapp.validator.MultiRegistrationAction"
           name="multiRegistrationForm"
           scope="request"
           validate="false">
   <forward name="success"             path="/index.jsp"/>
   <forward name="input1"              path="/multiRegistration1.jsp"/>
   <forward name="input2"              path="/multiRegistration2.jsp"/>
</action>

If the scope is request, how is it possible to retain the form
values until the last step?  If this is indeed an issue, perhaps it
should be updated before struts 1.1  (I would also comment on the
validate="false" but I know that is a bug in the DynaValidatorForm
with multipages, so I will leave that argument until post-1.1).

Dan

-- 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
Daniel Allen, <da...@mojavelinux.com>
http://www.mojavelinux.com/
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
There is no such thing as a casual knowledge of xslt, either 
you know everything about it or you are sitting in the creek.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

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


Re: multipage form struts example

Posted by Dan Allen <da...@mojavelinux.com>.
> > > Correct me if I am wrong, but if you are doing a multipage form you
> > > have to put the form into the session scope in order to retain it
> > > throughout the duration of the wizard, am I right?  The only way to
> > > avoid it would be to place hidden fields in the second and third
> > > pages to hold the values so they continue to get passed along which
> > > would be ridiculous.
> > >
> 
> Not at all ridiculous if you are so concerned about memory occupancy of
> session attributes (which some folks are) and ban the use of sessions.

oh don't worry, I'm not concerned about this occupancy at all...quite the
contrary actually, I really like what sessions can do for the
organization.

> 
> Using a session-based form bean is nicer for the page author (because they
> don't have to add so many hidden variables to all their pages), but this
> approach is very much a viable alternative.

I think we agree here.  I have been using session for this exact
purpose and it makes life grand.  I was just wondering why the
example application is broken and if it is going to be fixed.
Because if I try it, after submitting page two it takes me back to
page one and tells me none of the data is filled out.

I don't think hidden fields are evil at all (they are no different
than regular fields except in appearance).  I was just saying that
by using hidden fields in a multipage form, you have to move around
a lot of lines if you want to change which page certain information
is on.  By using session scopes, you can forget about what fields
are where until the very last Submit.

This discussion has cleared up any confusion I had on how to
organized my data over multiple pages.

Dan

-- 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
Daniel Allen, <da...@mojavelinux.com>
http://www.mojavelinux.com/
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
"The Linux philosophy is to laugh in face of danger.  Oops. 
Wrong one. 'Do it yourself' That's it" 
 -- Linus Torvalds
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

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


Re: multipage form struts example

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Sun, 6 Apr 2003, Dan Allen wrote:

> Date: Sun, 6 Apr 2003 13:13:11 -0500
> From: Dan Allen <da...@mojavelinux.com>
> Reply-To: Struts Users Mailing List <st...@jakarta.apache.org>
> To: Struts-User List <st...@jakarta.apache.org>
> Subject: Re: multipage form struts example
>
>
> Dan Allen (dan@mojavelinux.com) wrote:
>
> > Correct me if I am wrong, but if you are doing a multipage form you
> > have to put the form into the session scope in order to retain it
> > throughout the duration of the wizard, am I right?  The only way to
> > avoid it would be to place hidden fields in the second and third
> > pages to hold the values so they continue to get passed along which
> > would be ridiculous.
> >

Not at all ridiculous if you are so concerned about memory occupancy of
session attributes (which some folks are) and ban the use of sessions.

Using a session-based form bean is nicer for the page author (because they
don't have to add so many hidden variables to all their pages), but this
approach is very much a viable alternative.

> > The reason I bring this up because the following snippet shows up in
> > the validator example that ships with struts:
> >
> > <!-- Multi-Part Registration Action -->
> > <action    path="/multiRegistration"
> >            type="org.apache.struts.webapp.validator.MultiRegistrationAction"
> >            name="multiRegistrationForm"
> >            scope="request"
> >            validate="false">
> >    <forward name="success"             path="/index.jsp"/>
> >    <forward name="input1"              path="/multiRegistration1.jsp"/>
> >    <forward name="input2"              path="/multiRegistration2.jsp"/>
> > </action>
> >
> > If the scope is request, how is it possible to retain the form
> > values until the last step?  If this is indeed an issue, perhaps it
> > should be updated before struts 1.1  (I would also comment on the
> > validate="false" but I know that is a bug in the DynaValidatorForm
> > with multipages, so I will leave that argument until post-1.1).
>
> I would really be interested in other's thoughts on this one.  If it
> is a bug I think it would be important to fix so that it does not
> lead to unnecessary posts on the list.
>

Hidden variables are *not* evil :-).

> Dan
>

Craig

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


Re: multipage form struts example

Posted by Troy Hart <th...@part.net>.
It shows that the struts form is in request scope. It makes absolutely 
no inference about your model object.

Troy

Dan Allen wrote:

>Troy Hart (thart@part.net) wrote:
>
>  
>
>>The approach I use for this is to have a model object in my session that 
>>maintains the state. The controller uses the "multipage" struts form to 
>>update the model object's state as the user navigates the UI .... The 
>>controller will also use my model object to populate properties on the 
>>"multipage" struts form as needed.
>>    
>>
>
>Exactly what I did, which is why I believe the example is incorrect
>because it specifies that the data is in request scope which is not
>possible to maintain over more than one request.
>
>Dan
>
>  
>



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


Re: multipage form struts example

Posted by Dan Allen <da...@mojavelinux.com>.
Troy Hart (thart@part.net) wrote:

> The approach I use for this is to have a model object in my session that 
> maintains the state. The controller uses the "multipage" struts form to 
> update the model object's state as the user navigates the UI .... The 
> controller will also use my model object to populate properties on the 
> "multipage" struts form as needed.

Exactly what I did, which is why I believe the example is incorrect
because it specifies that the data is in request scope which is not
possible to maintain over more than one request.

Dan

-- 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
Daniel Allen, <da...@mojavelinux.com>
http://www.mojavelinux.com/
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
[Frodo]: "He deserves death." 
[Gandalf]: "Deserves it! I daresay he does. Many that live 
deserve death. And some that die deserve life.  Can you give 
it to them?  Then do not be too eager to deal out death in 
judgement. For even the very wise cannot see all ends."
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

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


Re: multipage form struts example

Posted by Troy Hart <th...@part.net>.
The approach I use for this is to have a model object in my session that 
maintains the state. The controller uses the "multipage" struts form to 
update the model object's state as the user navigates the UI .... The 
controller will also use my model object to populate properties on the 
"multipage" struts form as needed.

Troy



Dan Allen wrote:

>Dan Allen (dan@mojavelinux.com) wrote:
>
>  
>
>>Correct me if I am wrong, but if you are doing a multipage form you
>>have to put the form into the session scope in order to retain it
>>throughout the duration of the wizard, am I right?  The only way to
>>avoid it would be to place hidden fields in the second and third
>>pages to hold the values so they continue to get passed along which
>>would be ridiculous.
>>
>>The reason I bring this up because the following snippet shows up in
>>the validator example that ships with struts:
>>
>><!-- Multi-Part Registration Action -->
>><action    path="/multiRegistration"
>>           type="org.apache.struts.webapp.validator.MultiRegistrationAction"
>>           name="multiRegistrationForm"
>>           scope="request"
>>           validate="false">
>>   <forward name="success"             path="/index.jsp"/>
>>   <forward name="input1"              path="/multiRegistration1.jsp"/>
>>   <forward name="input2"              path="/multiRegistration2.jsp"/>
>></action>
>>
>>If the scope is request, how is it possible to retain the form
>>values until the last step?  If this is indeed an issue, perhaps it
>>should be updated before struts 1.1  (I would also comment on the
>>validate="false" but I know that is a bug in the DynaValidatorForm
>>with multipages, so I will leave that argument until post-1.1).
>>    
>>
>
>I would really be interested in other's thoughts on this one.  If it
>is a bug I think it would be important to fix so that it does not
>lead to unnecessary posts on the list.
>
>Dan
>
>  
>



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


Re: multipage form struts example

Posted by Dan Allen <da...@mojavelinux.com>.
Dan Allen (dan@mojavelinux.com) wrote:

> Correct me if I am wrong, but if you are doing a multipage form you
> have to put the form into the session scope in order to retain it
> throughout the duration of the wizard, am I right?  The only way to
> avoid it would be to place hidden fields in the second and third
> pages to hold the values so they continue to get passed along which
> would be ridiculous.
> 
> The reason I bring this up because the following snippet shows up in
> the validator example that ships with struts:
> 
> <!-- Multi-Part Registration Action -->
> <action    path="/multiRegistration"
>            type="org.apache.struts.webapp.validator.MultiRegistrationAction"
>            name="multiRegistrationForm"
>            scope="request"
>            validate="false">
>    <forward name="success"             path="/index.jsp"/>
>    <forward name="input1"              path="/multiRegistration1.jsp"/>
>    <forward name="input2"              path="/multiRegistration2.jsp"/>
> </action>
> 
> If the scope is request, how is it possible to retain the form
> values until the last step?  If this is indeed an issue, perhaps it
> should be updated before struts 1.1  (I would also comment on the
> validate="false" but I know that is a bug in the DynaValidatorForm
> with multipages, so I will leave that argument until post-1.1).

I would really be interested in other's thoughts on this one.  If it
is a bug I think it would be important to fix so that it does not
lead to unnecessary posts on the list.

Dan

-- 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
Daniel Allen, <da...@mojavelinux.com>
http://www.mojavelinux.com/
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
"The Linux philosophy is to laugh in face of danger.  Oops. 
Wrong one. 'Do it yourself' That's it" 
 -- Linus Torvalds
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

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