Examples of configuring Validator to use alternative/non-default resource bundles.
struts-config-bundles.xml
validation-bundles.xml
Notes on Using Validator and Resources/Bundles:
- Non-Resource Messages: - you can specify error messages directly in the validation.xml file using by setting resource="false" in <msg> element. Validation for the name field is an example of this.
- Alternative Bundles for Messages - specifying an alternative bundle for an error message in the validation.xml file (using <msg bundle="altBundle"/>) takes precedence over any bundle specified in the <html:errors/>, <html:messages/> or <html:javascript/> tags.
- Alternative Bundles for Arguments - specifying an alternative bundle for an error message argument in the validation.xml file (using <arg bundle="altBundle"/>) takes precedence over any bundle specified in the <html:errors/>, <html:messages/> or <html:javascript/> tags.
- If you specify an alternative bundle for a message (using <msg bundle="altBundle"/>) , any <arg> elements which don't have a bundle specified also inherit the same bundle. Validation for the address field is an example of this.
- Validation for the Date of Birth field uses the default bundle for the message, but specifies and alternative bundle for the argument.
- The <html:javascript/> tag now has a bundle attribute, so that the JavaScript messages can be generated in the same way as the <html:errors/> and <html:messages/> tags.