You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Adam Hardy <ad...@altavista.com> on 2002/02/22 11:01:07 UTC

ActionForm, initialization, submit back to same Action, validation, ActionErrors

Hi All,

I've read a few posts in the archives and not seen anything conclusive on this apart from the recommendation to stick to 

action -> page -> action

What I want to do is this:

firstpage -> action1 -> formpage1 -> action1 -> action2 -> page2 etc

I've just got to the point where I'm coding the validation for form1 and I am getting all my validation ActionErrors appearing when I first call up the form page. Since it's the first time I'm calling this page, I don't want anything validated at all. 

Do I have to switch validation off with a switch in my ActionForm validate method, or am I doing something wrong? 

Or should I define an ActionMapping with validation set to false to display this form page for the first time, and have the form submit to another ActionMapping with validation set to true?

Just wondering if I've missed something important.

Thanks
Adam


Find the best deals on the web at AltaVista Shopping!
http://www.shopping.altavista.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: ActionForm, initialization, submit back to same Action,validation, ActionErrors

Posted by Ted Husted <hu...@apache.org>.
Adam Hardy wrote:
> Or should I define an ActionMapping with validation set to false to display this form page for the first time, and have the form submit to another ActionMapping with validation set to true?

Yes. This is why there *is* a validation switch. =:o)


> Just wondering if I've missed something important.

If you are forwarding an ActionForm between Actions 

action1 -> action2

it can be helpful to have a switch in your base ActionForm to make it
immutable. This way the controller won't step on any changes you make to
the form, and avoids mucking about with dynamic ActionForwards. See the
http.SuperForm in the contrib/scaffold package for an example.

For multipage forms (wizard workflows), it's often helpful to define a
property on your form to give validate a clue as to what fields it
should be working with. The ValidatorForm handles this rather well. 
There is a page property, and you can assign each field to a page in the
configuration file. The validator then only validates fields with a page
equal to or less then the current page number. If things get moved
around, you can just reflect the changes in the configuration file.
(Then just be careful about what you do in reset.)


-- Ted Husted, Husted dot Com, Fairport NY US
-- Developing Java Web Applications with Struts
-- Tel: +1 585 737-3463
-- Web: http://husted.com/about/services

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>