You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Diego <di...@xeridia.com> on 2004/04/15 15:36:49 UTC

Complex validation

Hi everyone. I need to perform conditional validation in one of my forms. I have
a drop-down list and a text field. The validation applied to the text field
should be dependent on the value selected on the drop-down list. Is this
possible, using the Struts validator? I've taken a look at the "validwhen"
validator but I don't see how could this be done. I want a solution that allows
me to use Javascript validation.

Thanks in advance.

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.


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


Re: Complex validation

Posted by Christian Bollmeyer <ja...@christianbollmeyer.de>.
On Thursday 15 April 2004 15:36, Diego wrote:

I admit having but limited experience with Validator,
and DynaActionForm, and the reason for that is
not that it's bad in itself, but I found that complex,
in particular application specific 'dependant' validation
can be performed much easier by using traditional
ActionForms and the validate() method. That said,
I usually validate twice, once in the Presentation
tier and another time in the Business Logic, and
I almost never use or even rely on JavaScript, but
do strict server-side validation for that's a secure
area (while JavaScript can be easily turned off).
IMHO it's preferable to have the user spend an
additional roundtrip in case of inconsistent data
and issue some consolidated warnings in red
than pre-checking on the client tier via JavaScript
which ends up in a nameless message box. So
for me, the Validator generally is a good thing
(and crucial when using DynaActionForms), but
upon finding out it also has definite lackings
when doing complex validation, I dropped the
entire DynaActionForm approach and went
back to traditional ActionForms. For I found
that I finally was spending more time on
Validator XML definitions than it takes to
generate the entire ActionForm class itself
(Oracle JDev and NetBeans have a really
useful Beans editor here) and just code
the necessary validation code by hand.
The advantage is that I can see what's
happening directly in the Debugger instead
of endlessly interpreting log files and
adapting boring XML definitions. But
it's a matter of taste, after all, as always.

HTH,
-- Chris.
 

> Hi everyone. I need to perform conditional validation in one of my
> forms. I have a drop-down list and a text field. The validation
> applied to the text field should be dependent on the value selected
> on the drop-down list. Is this possible, using the Struts validator?
> I've taken a look at the "validwhen" validator but I don't see how
> could this be done. I want a solution that allows me to use
> Javascript validation.
>
> Thanks in advance.
>
> ----------------------------------------------------------------
> This message was sent using IMP, the Internet Messaging Program.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org

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


Re: Complex validation

Posted by Bill Siggelkow <bi...@bellsouth.net>.
Validator does not provide client-side (JavaScript) validation for 
"requiredif" and "validwhen".  It is my understanding that it is not 
practical to create a JavaScript reusable, generic function for these 
validations that plays in the Validator framework.

However, if you really need this validation client-side than writing a 
one-off JS function to perform this check is not that difficult.  You 
might want to check out a good JavaScript site (there are several -- 
just google JavaScript) -- in addition, the O'Reilly JavaScript book is 
a must-read if you are doing a lot of JS.

Diego wrote:

> Hi everyone. I need to perform conditional validation in one of my forms. I have
> a drop-down list and a text field. The validation applied to the text field
> should be dependent on the value selected on the drop-down list. Is this
> possible, using the Struts validator? I've taken a look at the "validwhen"
> validator but I don't see how could this be done. I want a solution that allows
> me to use Javascript validation.
> 
> Thanks in advance.
> 
> ----------------------------------------------------------------
> This message was sent using IMP, the Internet Messaging Program.


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