Using Validator with Modules

 < Day Day Up > 



Using Validator with modules works the same way as it does with a nonmodularized application. You simply add the Validator plugin to each module's Struts configuration file. Doing so allows each module to specify its own module-specific Validator configuration file, as shown next:

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

In this example, the first configuration file specified with the pathnames property is the validator-rules.xml file. Recall from Chapter 6 that this file is used to declaratively plug in the validation routines that Validator will use to perform validations. Because validation routines are typically the same across all modules, you do not have to create a validator-rules.xml file for each module. Instead, you simply point each module's Validator plugin to the one common file. However, using modules does allow you to specify a unique Validator rules configuration file for each module.

The second configuration file specified with the pathnames property is the module- specific Validator configuration file. This file should include all of the validation definitions specific to the given module.



 < 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