File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Struts2 - Conditional validation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts2 - Conditional validation" Watch "Struts2 - Conditional validation" New topic
Author

Struts2 - Conditional validation

James Dutt
Greenhorn

Joined: Apr 16, 2009
Posts: 9
I have tabs created using jquery in a struts2 form. At a given point of time, I will enter values for fields in any one of the tab and submit it. Rest of the tabs' fields will be blank. I have validation rule set for all the fields in all the tabs using action-validation.xml. So the validation is fired for all fields - as all the tabs& fields are in one <form>.

Stating this, Can I control the validation to only one tab and ignore other tab fields in action-validation.xml? We have something called depends="validwhen" in struts 1.x. Do we have something like that in struts2? the short-circuit is useful only to ignore rest of the validation set for a single field. correct me if i am wrong. Bottom line is, even though my form submits all the fields, I want my action-validation.xml to validate only the fields in active tab. Any thoughts?

Please let me know.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Expression validation can validate against any OGNL expression.

That said, it might be easier and/or more maintainable to do complicated validation in Java, possibly combined with XML- or annotation-based validation. Just keep a hidden value indicating which tab you're on.
 
 
subject: Struts2 - Conditional validation