Choose a validator tag for example, ValidateDateTimeRange.

6-14 Web User Interface Developers Guide for Oracle Application Development Framework 4. Add the required validation logic. This logic should use the javax.faces.validator.ValidatorException exception to throw the appropriate exceptions and the javax.faces.application.FacesMessage error message to generate the corresponding error messages. For more information about the Validator interface and FacesMessage, see the API documentation for javax.faces.validator.ValidatorException and javax.faces.application.FacesMessage, or visit http:download.oracle.comdocscdE17410_ 01javaeeindex.html .

6.6.2 What Happens When You Create a Backing Bean Validation Method

When you create a validation method, JDeveloper adds a skeleton method to the managed bean you selected. Example 6–11 shows the code JDeveloper generates. Example 6–11 Managed Bean Code for a Validation Method public void inputText_validatorFacesContext facesContext, UIComponent uiComponent, Object object { Add event code here... } When the form containing the input component is submitted, the method to which the validator attribute is bound is executed.

6.6.3 How to Create a Custom JSF Validator

Creating a custom validator requires writing the business logic for the validation by creating a Validator implementation of the interface, and then registering the custom validator with the application. You can also create a tag for the validator, or you can use the f:validator tag and the custom validator as an attribute for that tag. You can then create a client-side version of the validator. ADF Faces client-side validation works in the same way that standard validation works on the server, except that JavaScript is used on the client. JavaScript validator objects can throw ValidatorExceptions exceptions and they support the validate method. To create a custom JSF validator: 1. Create a Java class that implements the javax.faces.validator.Validator interface. The implementation must contain a public no-args constructor, a set of accessor methods for any attributes, and a validate method to implement the Validator interface. public void validateFacesContext facesContext, UIComponent uiComponent, Object object throws ValidatorException { .. } For more information about these classes, refer to the API documentation or visit http:download.oracle.comdocscdE17410_ 01javaeeindex.html . 2. Add the needed validation logic. This logic should use the javax.faces.validate.ValidatorException exception to throw the appropriate exceptions and the javax.faces.application.FacesMessage error message to generate the corresponding error messages. For more information