O'Reilly logo

Programming Jakarta Struts, Second Edition by Chuck Cavaness

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required