Home

This Chapter
-Chapter 5: The Validator Plugin
-The Default Validators
-Using Validator
-Understanding Validation Files
-Using Client Side Validation
-Using DynaValidatorForm
-Mixing Validator with Custom Validation
-Declaring Action-Based Rules
-Writing Custom Validators
-Custom Validator with Client Side Validation
-Using validwhen
-Summary

Table of Contents
-Introduction
-Chapter 1: Model 2 and Struts
-Chapter 2: Input Validation with Action Forms
-Chapter 3: The HTML Tag Library
-Chapter 4: Input Validation and Data Conversion
-Chapter 5: The Validator Plugin
-Chapter 6: The Expression Language
-Chapter 7: JSTL
-Chapter 8: The Bean Tag Library
-Chapter 9: The Logic Tag Library
-Chapter 10: Struts-EL, Nested, selectLabel
-Chapter 11: Message Handling and Internationalization
-Chapter 12: The Tiles Framework
-Chapter 13: Securing Struts Applications
-Chapter 14: The Config Object
-Chapter 15: The Persistence Layer
-Chapter 16: Object Caching
-Chapter 17: File Upload and File Download
-Chapter 18: Paging and Sorting
-Chapter 19: Preventing Double Submits
-Chapter 20: Early HttpSession Invalidation
-Chapter 21: Decorating Request Objects
-Chapter 22: How Struts Works

Previous
Next

 

Chapter 5

The Validator Plugin

You have seen how easy it is to write user input validation rules in actions forms. Struts goes the extra mile to make input validation even easier by providing the Validator plugin. Using this plugin, you do not even have to write Java code to validate user input. On top of that, the Validator plugin caters for client side validation, dynamic action forms, multipage forms, and custom validators. This is a boon to Struts developers because this means more rapid development. This chapter discusses the benefits of this plugin and explains how to use and extend it.

With the Validator plugin, you write validation rules instead of Java code. Validator comes bundled with default validators that are sufficient for most applications. If you have a specific need, you can extend your action form to handle action form’s properties that need special validating, and at the same time let Validator handle the rest. Alternatively, if the specific validation is required by other parts of your application, you can write it into a validator and plug it into Validator.

This chapter covers the Validator plugin in minute detail by featuring eight sample applications. It starts by introducing and giving you the first taste of the plugin. It then discusses the default validators included in the Validator plugin and the format of validation files. The last sections teach you how to write custom validators and the most complex of the default validators, validwhen.

Previous
Next