Saturday, October 29, 2011

Field Validation in ADF as user Tab out

In this blog I am trying to show validation as user tab out any field in ADF. User enter data in a form field and as he tab out the field validation happens and If validation criteria does not meet error message appears.


An ADF application has model and ViewController project. We can create the form in ViewController project. Please follow my previous blogs for the basics of Form generation in ViewController project. So rather than spending much time on the basics like Form generation , I would like to show special things I have done here to accomplish above goal.

Step1: Create a java class and implement javax.faces.validator.Validator, Implementation of Validator will ask for the validate(FacesContext facesContext, UIComponent uiComponent,Object object) method to be Implemented. Here I have created a java class named EmailValidator. This java file can be downloaded from link. Similarly we can create another java file for date validation. Please download the same from link.

Step2: Declare these java files as validator in faces-config.xml file. Please refer below snapshot


Step3: Modify your form so that it will not obey default validator and follow the custom validator you have created in step2. Please follow below entry in your jsff file.


Please download the jsff file from below link

Please deploy and it will work as expected.


No comments:

Post a Comment