Designer 10.15 | webMethods CAF and OpenUI Development | Using Converters and Validators | Creating a Custom Validator
 
Creating a Custom Validator
To create a custom validator, you need Java coding experience. Composite Application Framework provides some initial code to get you started. A custom validator is valid only for the portlet in which it is created. If you plan to use a particular validator in many portlets, create your own library and load it through the project.
*To create a custom validator
1. Open a CAF view in the design canvas and select the input control for which you want to create a custom validator.
2. In the Properties view, click the General tab.
3. In the ID field, type a unique ID for the validator.
4. In the design canvas, right-click the control, and then click Lifecycle > Custom Validator.
Composite Application Framework creates some Java code in the managed bean and opens a Java editor to the location of the code. An example of validator code created for an input control is shown here:
/**
* Validator for the control with id='inputID'
*/
public void inputID_validator(javax.faces.context.FacesContext
context, javax.faces.component.UIComponent component, java.lang.Object
value) {
// TODO: Check the value parameter here, and if not valid,
do something like this:
// throw new ValidatorException(new FacesMessage("Not a valid value!"));
}
5. After the TODO comments, type the Java code required for the validator.
Related Topics