2.1.7. Create and Register a Custom Validator

With the help of JBDS it's also quite easy to develop your own custom Validators. You should perform the actions similar to previous. Go through the following steps:

  • In the Project Explorer view open faces-config.xml and select Tree tab.

Validator in Faces Config Editor

Figure 2.50. Validator in Faces Config Editor


  • Select Validators and click on Add button.

  • Type the name of your validator in the Validator-id field and name of the class for validators. After clicking Finish button your custom validator is registered under the entered name.

Adding Validator

Figure 2.51. Adding Validator


Now you can create the "validator" class.

  • In the Validator section you can see your Validator-id and Validator-class . To generate the source code click on Validator-class.

Creating Validator Class

Figure 2.52. Creating Validator Class


  • Java class will be created automatically. Leave everything without changes and click Finish.

New Java Class Form

Figure 2.53. New Java Class Form


  • To open validator class click again on Validator-Class link in the Validator section. Now you are able to write a business logic of validator in the Java editor.

Converter Class Editing

Figure 2.54. Converter Class Editing