Creating and Registering a New Validator Method on a Component

To bind to a new validator method in a new or existing backing bean:

  1. In the Visual Editor, select the input component on which you wish to add a new bean and method.
  2. In the Property Inspector, click the column next to the Validator property, then click edit button to display the Validator dialog.
  3. To create a new method in an existing bean, select a name from the Managed Bean dropdown list. Go to step 5.
  4. To create a new bean and method, click N ew... next to the Managed Bean dropdown list. Enter the required information in the Create Managed Bean dialog. Click Help if you need more information about using the dialog. Make sure you check the Generate Java File box, then click OK. The Validator dialog redisplays.
  5. Click New... next to the Method dropdown list. The New Method dialog displays.
  6. Enter a method name and click OK. The Validator dialog redisplays.
  7. Click OK.
  8. To add code for the new method, open the .java file by double-clicking its filename in the Application Navigator. Type the code for the new method, then save the file.

Code sample

<h:selectOneMenu ...
                 validator="#{MyBean.somevalidatemethod}">
  ...
</h:selectOneMenu>    

About Custom JSF Validators
Registering a Custom Converter or Validator in an Application
Registering a Custom Validator on a Component
Referencing an Existing Bean Method That Performs Validation
Registering a Standard Validator on a Component