struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shannon, Andrew" <>
Subject RE: Advanced Struts 2 Validation Question...
Date Thu, 13 Nov 2008 23:01:21 GMT
I'd have to second that.  Writing validation in java code that is.
We've been creating a few different patterns to try and do this in an
intelligent manner, especially where we might need to go to the database
and get some data or rules or something.  I think one of the biggest
benefits about this is that we can unit test the heck out of it to our
satisfaction which alleviates the burden of working through all the
validation machinatinos in web-based integration tests as well as
trimming real people testing time which is important for the tight
budget on my current project.

- Andrew

-----Original Message-----
From: Burton Rhodes [] 
Sent: Thursday, November 13, 2008 11:25 AM
To: Struts Users Mailing List;
Subject: Re: Advanced Struts 2 Validation Question...

Thanks to all!  Implementing Validatable was simple and works great.
I am thinking of moving all my action objects that need it to
Validatable. per Bill's suggestion...  one less file to worry about.

On Thu, Nov 13, 2008 at 9:58 AM, Dave Newton <>
> --- On Thu, 11/13/08, Burton Rhodes wrote:
>> How do I use validation in an [Action]-validation.xml file
>> to validate several fields?
>> I need to implement the following logic for 3 fields on a
>> form: Company, FirstName, LastName.
>> Psedo Code:
>> If Company empty, then FirstName and LastName must be filled
>> If FirstName and LastName empty, then Company Must be filled.
>> I am having trouble seeing how this can be accomplished
>> with the "expression" validator type.
> Besides the expression help already provided, I'd add that personally
I'd put this in the Java code rather than in the XML file.
> It's probably just me, so take it with a grain of salt--as soon as
anything gets even a little bit complicated (this usage might not
qualify as "complicated" since it's trivial, so it's on the edge) I'll
put it in a validate() method, possibly calling super.validate() to
handle simple XML-based validations. It's (generally) easier to debug in
the Java code.
> With regards to doing it via JavaScript, sure, that's a viable
solution, but until I actually *apply* my patch to allow quick and easy
custom JavaScript validations you'll have to take the route of modifying
the template as another poster mentioned, or do it a bit more outside of
the S2 JavaScript validation.
> (Hopefully I'll get to the patch this weekend, and I'll put it in a
JIRA issue including the patch so people can use it with
previously-released versions.)
> Dave
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message