Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts2 - Conditional validation

 
James Dutt
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic