Book Image

Oracle ADF Faces Cookbook

By : Amr Gawish, Amr Ismail Gawish
Book Image

Oracle ADF Faces Cookbook

By: Amr Gawish, Amr Ismail Gawish

Overview of this book

Table of Contents (18 chapters)
Oracle ADF Faces Cookbook
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Creating a custom JSF validator


JSF provides an easy way to create custom validation logic to meet your business needs.

If this validation only occurs in a single page, then you may consider using validation inside the page-managed bean. However, if you want this validation to be used in different components or in different pages, consider creating a JSF validator.

In this recipe, we will create a custom validator for the employee's email attribute that needs to start with the first letter of his first name. You can continue from the previous recipe, or you can grab this project's recipe by cloning the CreateCustomJSFValidator application from the Git repository.

Getting ready

In order to create custom JSF validator, we need to perform the following steps:

  1. Create a class that implements the javax.faces.validattor.Validator interface.

  2. Implement the validate method.

  3. Register this class as a validator inside the faces-config.xml file.

  4. Apply the validator on input components.

How to do it…

To know how...