You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Gregory F. March" <ma...@gfm.net> on 2003/06/13 14:40:13 UTC

conditional validation in validation.xml

I'm using a DynaValidatorForm with validation rules in
validation.xml.  My form is a multipage form, and I (obviously) would
like to validate only the parameters "in scope" for the current page.

Can this be done through the xml file (if so, how)?  Or do I need to
write my own validation class that looks at a "page" variable?

Thanks!

/greg

--
Gregory F. March    -=-    http://www.gfm.net:81/~march    -=-    AIM:GfmNet

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


Re: conditional validation in validation.xml

Posted by Jordan Reed <jo...@hotmail.com>.
The Validator has some concept with the page attribute.  If you look at the
"Multi Page Form" section you get a hint at it:
http://jakarta.apache.org/struts/userGuide/dev_validator.html


In your jsp you need an element called page.  I usually just put a static
hidden tag:
<html:hidden property="page" value="2"/>

Then in your validation.xml you associated a page number with the element:
<field property="user.firstName" depends="required" page="2"/>

So what the validator does is only validate the field if the page attribute
is >=.

So for this example above... The "user.firstName" field would NOT be
validated on page 1, but would be validated on page 2, page 3, etc.

-Jordan Reed (http://www.chaosserver.net)



On 6/13/03 5:40 AM, "Gregory F. March" <ma...@gfm.net> wrote:

> 
> I'm using a DynaValidatorForm with validation rules in
> validation.xml.  My form is a multipage form, and I (obviously) would
> like to validate only the parameters "in scope" for the current page.
> 
> Can this be done through the xml file (if so, how)?  Or do I need to
> write my own validation class that looks at a "page" variable?
> 
> Thanks!
> 
> /greg
> 
> --
> Gregory F. March    -=-    http://www.gfm.net:81/~march    -=-    AIM:GfmNet


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