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.

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.

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. ...

Get Programming Jakarta Struts, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.