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 Struts 1.3 Configuring different set of validations for the same ActionForm Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts 1.3 Configuring different set of validations for the same ActionForm" Watch "Struts 1.3 Configuring different set of validations for the same ActionForm" New topic
Author

Struts 1.3 Configuring different set of validations for the same ActionForm

Karthik Vijayarajan
Ranch Hand

Joined: Mar 13, 2005
Posts: 43
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.


Karthik <br />SCJP 1.4 SCWCD 1.4 SCBCD 1.3
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
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.


Merrill
Consultant, Sima Solutions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts 1.3 Configuring different set of validations for the same ActionForm