mask ${phone} minLength 5 The last of the field child elements is the var element, as seen in Example 11-1 and in the previous fragment. The var element can set parameters that a field element may need to pass to one of its validation rules, such as the minimum and maximum values in a range validation. These parameters may also be referenced by one of the argelements using a shell syntax: ${var:varname}. In Example 11-1, the substituted value for the phone constant is passed into the mask validation rule so that it can be used to check whether the property value conforms to the proper phone mask. The field element can have zero or more var elements. Once you have the two XML resource files configured for your application, you need to place them in the WEB-INF directory. They will be referenced within the Struts configuration file, as described in the next section. 11.2.3 Plugging In the Validator Each Struts application needs to know that the Validator framework is being employed. As discussed in Chapter 9, you can use the PlugIn mechanism to hook the Validator framework into a Struts application. Earlier versions of the Validator used an extra servlet to inform the Struts application that the Validator components were present. The ValidatorServlet has been deprecated and should not be used. The following fragment illustrates how to set up the Validator as a plug-in:
There was some confusion in one of the earlier beta releases for the Validator that used multiple set-property elements. That is no longer supported you should use a single set-property element that specifies multiple Validator resource files, separated by commas. Also notice that the property value is the plural pathnames.
In case you need quality webspace to host and run your web applications, try our personal web hosting services.
This entry was posted
on Friday, August 24th, 2007 at 2:09 pm and is filed under Domain.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.