Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts 1.3 Configuring different set of validations for the same ActionForm

 
Karthik Vijayarajan
Ranch Hand
Posts: 43
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I am using Struts 1.3. I would like to use declarative validations for the action forms.
I have a JSP with two buttons - Save, Back. When i click on Save button, i would like to trigger the following validations :required, integer, intRange etc. And when i click on Back button, i wudnt want to use the 'required' validation. But i would still need the other validations like integer, intRange etc. Would it be possible to configure such type of validations in the validation xml? I browsed thru the struts validator manual, but couldnt find anything to relate to this kind of scenario. I contemplated using 'validWhen', but realized that it was meant for a different purpose.

I guess one of the options would be to not use the declarative validation and use the validate method in the ActionForms to differentiate between click of Save and Back buttons(with request parameters).

If you have any thoughts or suggestions, please let me know.Thanks.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One option would be to have your ActionForm extend ValidatorActionForm instead of ValidatorForm. You would then specify the action path as the name in your validation.xml file instead of the form name. This allows you to specify two different sets of validations for the same ActionForm. For more information see the Struts Javadoc for the above classes.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic