Enabling the Validator Plugin

 < Day Day Up > 



Although the Validator framework comes packaged with Struts, by default Validator is not enabled. In order to enable and use Validator, you have to add the following <plug-in> definition to your application's Struts configuration file:

<!-- Validator Configuration --> <plug-in className="org.apache.struts.validator.ValidatorPlugIn">   <set-property property="pathnames"                   value="/WEB-INF/validator-rules.xml,                          /WEB-INF/validation.xml"/> </plug-in>

This definition causes Struts to load and initialize the Validator plugin for your application. Upon initialization, the plugin loads the comma-delimited list of Validator configuration files specified by the 'pathnames' property. Each configuration file's path must be specified using a Web application-relative path, as shown in the preceding example.

Note that your application's Struts configuration file must conform to the Struts configuration file DTD, which specifies the order in which elements are to appear in the file. Because of this, you must place the Validator <plug-in> definition in the proper place in the file. The easiest way to ensure that you are properly ordering elements in the file is to use a tool, such as Struts Console, that automatically formats your configuration file so that it conforms to the DTD.



 < Day Day Up > 



Struts. The Complete Reference
Struts: The Complete Reference, 2nd Edition
ISBN: 0072263865
EAN: 2147483647
Year: 2003
Pages: 134
Authors: James Holmes

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net