You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Strachan, Paul" <Pa...@det.nsw.edu.au> on 2006/10/05 08:23:52 UTC

newbie action,form,validation design problem

Hi All,

 

(Struts 1.2.4, Validator 1.1.3)

 

I have a DispatchAction which forwards to 3 possible Jsps (populated by
a single DynaForm)

 

Next, I added validations for each of the 3 JSP pages but now each
validation is different, it seems I need to clone the forms ???

 

But, also it doesn't look like I can use multiple forms with my
DispatchAction, so I look toward a MappingDispatchAction (with cloned
form) for each JSP

 

So now my original action has to populate one of 3 different forms
before it forwards to that appropriate JSP -it doesn't seem right!

 

I shouldn't need to change my action and clone forms just to control the
form validation.   Can anyone please help spot the problem in this
design

 

 

Thanks,

 

Note: I can see a 'page' attribute on the validator, but I don't think
this quite fits my design

 


**********************************************************************
This message is intended for the addressee named and may contain
privileged information or confidential information or both. If you
are not the intended recipient please delete it and notify the sender.
**********************************************************************

Re: newbie action,form,validation design problem

Posted by Laurie Harper <la...@holoweb.net>.
Strachan, Paul wrote:
> Hi All,
> 
> (Struts 1.2.4, Validator 1.1.3)
> 
> I have a DispatchAction which forwards to 3 possible Jsps (populated by
> a single DynaForm)
> 
> Next, I added validations for each of the 3 JSP pages but now each
> validation is different, it seems I need to clone the forms ???
> 
> But, also it doesn't look like I can use multiple forms with my
> DispatchAction, so I look toward a MappingDispatchAction (with cloned
> form) for each JSP
> 
> So now my original action has to populate one of 3 different forms
> before it forwards to that appropriate JSP -it doesn't seem right!
> 
> I shouldn't need to change my action and clone forms just to control the
> form validation.   Can anyone please help spot the problem in this
> design
> 
> Thanks,
> 
> Note: I can see a 'page' attribute on the validator, but I don't think
> this quite fits my design

Well, without seeing your design, it's hard to guess what fits with it 
;-) However, here are a few things to look into:

1) you can validate based on the action mapping path (the 'path' 
attribte of the 'action' tag in struts-config.xml), rather than based on 
the name of the form. That's one easy way to apply different sets of 
validations to the same form w/out having to clone it.

2) you may well be able to 'repurpose' the 'page' attribute you mention; 
set it to a different value in each of your JSPs, and use that to key 
your validations. you may be able to use the same parameter to key the 
validation page as you use to dispatch, to keep things simple (not sure 
about that)

3) if you have a common set of fields that need to be validated the same 
for all 3 JSPs and only a few that vary, you may be able to use the 
'extends' feature to set up a base form + validation rules, to factor 
out the common stuff.

I haven't used the various types of dispatch action, so there may be 
additional options I'm not aware of.

L.


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