Understanding XML DTDs


Two Configuration Files

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, typically named 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, typically named 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.



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

Similar book on Amazon
Struts 2 in Action
Struts 2 in Action
Murach's Java Servlets and JSP, 2nd Edition
Murach's Java Servlets and JSP, 2nd Edition
Jakarta Struts For Dummies
Jakarta Struts For Dummies
Head First Servlets and JSP: Passing the Sun Certified Web Component Developer Exam
Head First Servlets and JSP: Passing the Sun Certified Web Component Developer Exam

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