jQuery in Action, 3rd edition
The moose likes Struts and the fly likes about validator.xml file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "about validator.xml file" Watch "about validator.xml file" New topic

about validator.xml file

surendar prabu
Ranch Hand

Joined: Jul 24, 2006
Posts: 102
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.


SCJP 1.4
Merrill Higginson
Ranch Hand

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

Consultant, Sima Solutions
I agree. Here's the link: http://aspose.com/file-tools
subject: about validator.xml file
It's not a secret anymore!