methodParams=”java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionErrors, javax.servlet.http.HttpServletRequest” msg=”errors.boolean”> The final step is to use the new validation rule in the validation.xml file. This involves creating a field element that matches a boolean property on an ActionForm: 11.5 The Validator and JSP Custom Tags Several JSP custom tags included within the Struts tag libraries can be used with the Validator framework. One of the tags is used to generate dynamic JavaScript based on the validation rules. The other tags are part of the core Struts framework and are used both with and without the Validator. The tags listed in Table 11-4 are generic and can be used with or without the Validator framework, but they all come in handy when using it. Table 11-4. JSP custom tags that can be used with the Validator Tag name Description Errors Displays any validation errors found during processing ErrorsExist Determines if there were any validation errors Messages Displays any messages found during processing MessagesExist Determines if there were any messages during processing The tags in Table 11-4 allow JSP pages to detect and obtain access to messages or errors that were detected in the Struts application. These tags were discussed in more detail in Chapter 8. 11.5.1 Using JavaScript with the Validator The Validator framework is also capable of generating JavaScript for your Struts application using the same framework as for server-side validation. This is accomplished by using a set of JSP custom tags designed specifically for this purpose. 11.5.1.1 Configuring the validation-rules.xml file for JavaScript The Validator custom tag called JavascriptValidator is used to generate client-side validation based on a javascript attribute being present within the validator element. Before the JSP custom tag can be used, there must be a javascript element for the validation rule. The following code fragment illustrates the required validation rule that includes a javascript element:
You need excellent and relaible webhost company to host your web applications? Then pay a visit to Inexpensive Web Hosting services.
This entry was posted
on Saturday, September 1st, 2007 at 12:01 am 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.