Can you be more specific? How far did you get? The book Professional Struts by Wrox covers it step by step. I know. I wrote that chapter. To use the Validator Framework, follow these steps: 1.Add the Validator Plugin to the Struts configuration file. 2.Copy the validator-rules.xml and validation.xml files into WEB-INF (from the blank Struts Web application). 3.Change the ActionForm class (UserRegistrationForm.java) to the subclass ValidatorForm (org.apache.struts.validator.ValidatorForm). 4.Add a form to the form set in the validation.xml file corresponding to the attribute name of the form. 5.Add a field to the form declaration in the validation.xml file corresponding to the userName field. 6.Specify that the userName field correspond to the required, minlength, maxlength rules. 7.Add the error message for the rules to the resource bundle. 8.Specify that the username label be the first argument to the error message. 9.Configure the rules. 10. Specify that the value of the rules' minlength variable be the second argument to the error message if there is a minlength rule violation. Do the same for the maxlength variable and the maxlength rule. 11. Turn on Logging
Step 1 is to add the Validator Plugin to the Struts configuration file. The Validator Framework integrates with Struts via this Plugin, which is responsible for reading the configuration files for the Validator rules. To use the Validator Framework with Struts, you need to add this Plugin after any message resource elements in the Struts configuration file as follows: <plug-in className="org.apache.struts.validator.ValidatorPlugIn"> <set-property property="pathnames" value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/> </plug-in>
Here is an example that validates a user name from a form:
The book Struts in Action also covers the Validator Framework.