Using Validator with modules works the same way as it does with a non-modularized 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="/org/apache/struts/validator/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 need 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 validation.xml 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.