Friday, December 16, 2011

Add Custom validator - nicely attached to InputText Field

After building your business components, and adding your view object through data controls to the jspx or jsff page as editiable field you need to do the following:

- Add a new Java bean to your application resources in my case I named it TestValidation.
- Select the InputText field, and in property inspector go to Behavior property, then inside Validator area select edit to add new custom validator.





- Then it will build a method inside your bean with list of params will be used during validation phase.






-  Write the business logic you need to check the value of the input filed, the object param contains the new entered value.
- Then throw the validationException with custom message to your current FacesContext.
- At runtime you will get a nicely error message attached to the InputText field.



No comments:

Post a Comment