Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Struts 2 »

Re: Struts 1.3.5 - Radio Button validation

Laurie Harper

2007-01-30

Replies:

Christopher Schultz wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Pushkar,
>
> pushkar.p@(protected):
>> Can you please tell me whether I can validate a set of radio buttons so that
>> atleast one of them is checked, using the struts validation.xml? Is there a
>> pre-defined validator method (like required) defined for that or will I have
>> to write a custom validator method?
>
> You want to look into using the "validwhen" validator, which requires
> some reading. Check out this page
> (http://struts.apache.org/1.3.5/faqs/validator.html) and read the
> section titled "Designing Complex Validations with validwhen"
>
> You'll want a field set up with a "validwhen" test like:
>
> ((*this* != null) or (otherField != null)) or (anotherField != null) ...

Actually, assuming it's a radion button group that maps to a single
property, you probably just need the 'required' validation to ensure
that property has a value. You should only need 'validwhen' if there are
multiple properties involved, or if you need to express complex
constraints on a single property.

L.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)

©2008 junlu.com - Jax Systems, LLC, U.S.A.