Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

about validator.xml file

 
surendar prabu
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

regards,
surendarprabu.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

See The validation section of the user guide for more details.

Here is a quote from it:

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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic