This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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.
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.