You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by David Winterfeldt <dw...@yahoo.com> on 2001/04/02 21:31:59 UTC

Multi-Page Forms

I know this has been discussed before, but I was in a
group and we were discussing if there was any way to
completely separate the view from the controller for
multi-page forms.  I've did a multi page example where
you specified what page you were on in a hidden field
and also associated a field with a page so the
validation would know what to validate.  

The best idea that came out of the group was to define
a separate action in the struts-config.xml that would
share the same Action and ActionForm class and have a
previous and next forward defined to navigate through
the multiple pages.  Validation would be performed by
checking the request object and using reflection to
only check the fields that were submitted.  This way
the page designer could just layout the pages and
define the actions and it keeps the view separate from
the controller.  As far as knowing when you were at
the end to run all validations again, I thought that
if there was no 'next' forward defined the controller
could look for a 'success' forward.

The only other issue left which is a pain is how to
deal with resetting default checkbox values (possibly
pass in the defaults along with the action so it isn't
hard coded?).  

Any thoughts, comments, or different ways of handling
this would be appreciated.

David

__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail. 
http://personal.mail.yahoo.com/?.refer=text

Re: Multi-Page Forms

Posted by John Sutherland <js...@appliedtheory.com>.
I came up with a rather unique way of handling multi-page forms.. The
nice thing is that it is completely seperate from the Action and Form
code.. You can switch from a single page form to a multipage form with
NO code changes.. I have typed up a quick document on it (I actaully
presented it to a few poeple at work...), and if you are nice to my
server (its a small box), you can view it at (w/ downloadable
examples..):

http://garion.appliedtheory.com/Forms_with_Struts.html

It involves a set of custom tags to implement a "controller" JSP..
Ignore the code, its not the best in the world, as I'm fairly new to
Java and also Struts..

-- 
John Sutherland
Software Engineer
JSutherl@AppliedTheory.com


Levi Cook wrote:
> 
> As an afterthought... I realized it may be useful to include my
> struts-config file too.. So here it is
> :)
> 
> -- Levi
> 
> ----- Original Message -----
> From: "Levi Cook" <le...@hotmail.com>
> To: <st...@jakarta.apache.org>
> Sent: Wednesday, April 04, 2001 8:38 AM
> Subject: Re: Multi-Page Forms
> 
> > Hi David,
> >
> > This isn't a complete solution (or explanation), but at a glance, I think
> it
> > may have some decent potential for mulitpage support.
> >
> > I followed your lead on declaritve validation, but took a slightly
> different
> > approach to its implementation.
> >
> > In a nutshell, creating a new form is completely unaware of its
> validation.
> > To create an "automatically" validated form, I just take the following two
> > steps:
> > 1. I place validation declarations in my Application.resources.
> > 2. Then my forms extend ValidationFormAdapter, and I will automagically be
> > validated.
> >
> > I've attached a zip file, which contains a preliminary round of the
> relevant
> > code. In particular, you're probably most interested in this hierarchy:
> > ContactForm extends ValidatingFormAdapter extends ValidatingForm extends
> > ActionForm <<struts>>
> >
> > As a peek, my declarations look like this:
> > contactForm.required.fields=firstName,lastName,emailAddress
> > contactForm.email.fields=emailAddress
> > contactForm.date.fields=birthDate
> >
> > I believe that I can modify my ValidationForm+ValidationFormAdapter, to
> > contain knowledge of what page, in a declared series I am working on.
> >
> > I'm interested in feedback from anyone, I also plan to announce a more
> > complete version of this app. in the near future.
> > Regards,
> > Levi Cook
> >
> >
> > ----- Original Message -----
> > From: "David Winterfeldt" <dw...@yahoo.com>
> > To: <st...@jakarta.apache.org>
> > Sent: Monday, April 02, 2001 2:31 PM
> > Subject: Multi-Page Forms
> >
> >
> > > I know this has been discussed before, but I was in a
> > > group and we were discussing if there was any way to
> > > completely separate the view from the controller for
> > > multi-page forms.  I've did a multi page example where
> > > you specified what page you were on in a hidden field
> > > and also associated a field with a page so the
> > > validation would know what to validate.
> > >
> > > The best idea that came out of the group was to define
> > > a separate action in the struts-config.xml that would
> > > share the same Action and ActionForm class and have a
> > > previous and next forward defined to navigate through
> > > the multiple pages.  Validation would be performed by
> > > checking the request object and using reflection to
> > > only check the fields that were submitted.  This way
> > > the page designer could just layout the pages and
> > > define the actions and it keeps the view separate from
> > > the controller.  As far as knowing when you were at
> > > the end to run all validations again, I thought that
> > > if there was no 'next' forward defined the controller
> > > could look for a 'success' forward.
> > >
> > > The only other issue left which is a pain is how to
> > > deal with resetting default checkbox values (possibly
> > > pass in the defaults along with the action so it isn't
> > > hard coded?).
> > >
> > > Any thoughts, comments, or different ways of handling
> > > this would be appreciated.
> > >
> > > David
> > >
> > > __________________________________________________
> > > Do You Yahoo!?
> > > Get email at your own domain with Yahoo! Mail.
> > > http://personal.mail.yahoo.com/?.refer=text
> >
> 
>   ------------------------------------------------------------------------
>                         Name: struts-config.xml
>    struts-config.xml    Type: text/xml
>                     Encoding: quoted-printable

-- 
John Sutherland
Software Engineer
JSutherl@AppliedTheory.com

Re: Multi-Page Forms

Posted by Levi Cook <le...@hotmail.com>.
As an afterthought... I realized it may be useful to include my
struts-config file too.. So here it is
:)

-- Levi

----- Original Message -----
From: "Levi Cook" <le...@hotmail.com>
To: <st...@jakarta.apache.org>
Sent: Wednesday, April 04, 2001 8:38 AM
Subject: Re: Multi-Page Forms


> Hi David,
>
> This isn't a complete solution (or explanation), but at a glance, I think
it
> may have some decent potential for mulitpage support.
>
> I followed your lead on declaritve validation, but took a slightly
different
> approach to its implementation.
>
> In a nutshell, creating a new form is completely unaware of its
validation.
> To create an "automatically" validated form, I just take the following two
> steps:
> 1. I place validation declarations in my Application.resources.
> 2. Then my forms extend ValidationFormAdapter, and I will automagically be
> validated.
>
> I've attached a zip file, which contains a preliminary round of the
relevant
> code. In particular, you're probably most interested in this hierarchy:
> ContactForm extends ValidatingFormAdapter extends ValidatingForm extends
> ActionForm <<struts>>
>
> As a peek, my declarations look like this:
> contactForm.required.fields=firstName,lastName,emailAddress
> contactForm.email.fields=emailAddress
> contactForm.date.fields=birthDate
>
> I believe that I can modify my ValidationForm+ValidationFormAdapter, to
> contain knowledge of what page, in a declared series I am working on.
>
> I'm interested in feedback from anyone, I also plan to announce a more
> complete version of this app. in the near future.
> Regards,
> Levi Cook
>
>
> ----- Original Message -----
> From: "David Winterfeldt" <dw...@yahoo.com>
> To: <st...@jakarta.apache.org>
> Sent: Monday, April 02, 2001 2:31 PM
> Subject: Multi-Page Forms
>
>
> > I know this has been discussed before, but I was in a
> > group and we were discussing if there was any way to
> > completely separate the view from the controller for
> > multi-page forms.  I've did a multi page example where
> > you specified what page you were on in a hidden field
> > and also associated a field with a page so the
> > validation would know what to validate.
> >
> > The best idea that came out of the group was to define
> > a separate action in the struts-config.xml that would
> > share the same Action and ActionForm class and have a
> > previous and next forward defined to navigate through
> > the multiple pages.  Validation would be performed by
> > checking the request object and using reflection to
> > only check the fields that were submitted.  This way
> > the page designer could just layout the pages and
> > define the actions and it keeps the view separate from
> > the controller.  As far as knowing when you were at
> > the end to run all validations again, I thought that
> > if there was no 'next' forward defined the controller
> > could look for a 'success' forward.
> >
> > The only other issue left which is a pain is how to
> > deal with resetting default checkbox values (possibly
> > pass in the defaults along with the action so it isn't
> > hard coded?).
> >
> > Any thoughts, comments, or different ways of handling
> > this would be appreciated.
> >
> > David
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Get email at your own domain with Yahoo! Mail.
> > http://personal.mail.yahoo.com/?.refer=text
>

Re: Multi-Page Forms

Posted by Levi Cook <le...@hotmail.com>.
Hi David,

This isn't a complete solution (or explanation), but at a glance, I think it
may have some decent potential for mulitpage support.

I followed your lead on declaritve validation, but took a slightly different
approach to its implementation.

In a nutshell, creating a new form is completely unaware of its validation.
To create an "automatically" validated form, I just take the following two
steps:
1. I place validation declarations in my Application.resources.
2. Then my forms extend ValidationFormAdapter, and I will automagically be
validated.

I've attached a zip file, which contains a preliminary round of the relevant
code. In particular, you're probably most interested in this hierarchy:
ContactForm extends ValidatingFormAdapter extends ValidatingForm extends
ActionForm <<struts>>

As a peek, my declarations look like this:
contactForm.required.fields=firstName,lastName,emailAddress
contactForm.email.fields=emailAddress
contactForm.date.fields=birthDate

I believe that I can modify my ValidationForm+ValidationFormAdapter, to
contain knowledge of what page, in a declared series I am working on.

I'm interested in feedback from anyone, I also plan to announce a more
complete version of this app. in the near future.
Regards,
Levi Cook


----- Original Message -----
From: "David Winterfeldt" <dw...@yahoo.com>
To: <st...@jakarta.apache.org>
Sent: Monday, April 02, 2001 2:31 PM
Subject: Multi-Page Forms


> I know this has been discussed before, but I was in a
> group and we were discussing if there was any way to
> completely separate the view from the controller for
> multi-page forms.  I've did a multi page example where
> you specified what page you were on in a hidden field
> and also associated a field with a page so the
> validation would know what to validate.
>
> The best idea that came out of the group was to define
> a separate action in the struts-config.xml that would
> share the same Action and ActionForm class and have a
> previous and next forward defined to navigate through
> the multiple pages.  Validation would be performed by
> checking the request object and using reflection to
> only check the fields that were submitted.  This way
> the page designer could just layout the pages and
> define the actions and it keeps the view separate from
> the controller.  As far as knowing when you were at
> the end to run all validations again, I thought that
> if there was no 'next' forward defined the controller
> could look for a 'success' forward.
>
> The only other issue left which is a pain is how to
> deal with resetting default checkbox values (possibly
> pass in the defaults along with the action so it isn't
> hard coded?).
>
> Any thoughts, comments, or different ways of handling
> this would be appreciated.
>
> David
>
> __________________________________________________
> Do You Yahoo!?
> Get email at your own domain with Yahoo! Mail.
> http://personal.mail.yahoo.com/?.refer=text