In my application i have multiple Actions and one ActionForm to carry all the properties. But each action populates a different set of properties in the ActionForm.
In my validator.xml in the form tag iam pointing to the ActionForm <form name="myForm">. But i need my ActionForm to be validated according to the ActionMapping that is according to the Action that is called. how can i acomplish this.
Joined: Feb 15, 2005
Make your ActionForm extend ValidatorActionForm instead of ValidatorForm. Then, in your validation.xml file, give the action path as the name attribute rather than the form name. You can then specify validations to be performed for each action, rather than for the entire form.
An alternative approach is to use the action mapping path attribute. In this case, you extend the ValidatorActionForm instead of the ValidatorForm. The ValidatorActionForm uses the action element's path attribute from the Struts configuration which should match the form element's name attribute in the Validator configuration.
Then a separate action mapping can be defined for each page in a multi-page form, and the validation form can be associated with the action rather than a page number (as shown in the example of a multi-page form in the validator example).
[ August 26, 2006: Message edited by: Merrill Higginson ]