Two Configuration Files

 < Day Day Up > 



In general, Validator uses two XML configuration files to tell it which validation routines should be “installed” and how they should be applied for a given application, respectively. The first configuration file, validator-rules.xml, declares the validation routines that are plugged into the framework and assigns logical names to each of the validations. Additionally, the validator-rules.xml file is used to define client-side JavaScript code for each validation routine. If configured to do so, Validator will emit this JavaScript code to the browser so that validations are performed on the client side as well as the server side. The second configuration file, validation.xml, defines which validation routines are applied to which Form Beans. The definitions in this file use the logical names of Form Beans from the Struts configuration file along with the logical names of validation routines from the validator-rules.xml file to tie the two together.

Although it is standard to use two configuration files for Validator, it is not technically required. Both configuration files must conform to the same DTD and thus could be combined into one large file that specifies both the validation routines and their use with forms. However, it’s advantageous to have the individual files because you can reuse the validation-rules.xml file in multiple applications. Similarly, if your application uses the Struts module feature, then you will likely have a validation.xml file for each module. Embedding the contents of validator-rules.xml in validation.xml would result in a great deal of redundancy in this scenario.



 < Day Day Up > 



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

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