The Validator Configuration File Tags


Enabling the Validator Plugin

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="/org/apache/struts/validator/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 or using a path to a file on the classpath of the server, as shown in the preceding example. The validator-rules.xml file shown in the preceding example happens to be stored in the core Struts .jar file and thus it is accessible via the classpath.

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.



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

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