Validation Configured with Localized Variables.
The purpose of this page is to demonstrate Validator configured to use variables from message resources. So, for example, the date validator can get the format appropriate for the user's Locale - enabling localized validation using just one form in the validation config file.
Information d'Employé
The above fields use the following validation rules in a localized way...
- Nom -
minlength and maxlength..
- Code Postal -
minlength, maxlength and validwhen..
- Numéro de téléphone -
mask.
- Date de naissance -
date(not strict) .
- Age -
intRange..
- La date d'Emploi -
date(strict).
- Nombre d'employé -
longRange..
- Salaire -
doubleRange..
- Heures -
floatRange..
Notes Below...
- The validation config is in validation.xml in the /webapps/struts-examples/WEB-INF/validator directory.
- Two message resources bundles have been used - one for normal text and the other for validation variables:
- General text (bundle key i18nExample) is in I18nExample.properties
- Validation variables (bundle key i18nVariables) are in I18nExampleVariables.properties
- N.B.Its important to configure the resource bundle containing validation variables to return null if not found. See the struts-config.xml for an example of this.