ADF custom validator – Example 


Business requires specific needs to validate data. Example: ‘SSN’. SSN is a 9-digit number and format should be like ‘000-000-0000’. ADF does not have any default validator to validate the SSN but ADF provides a way to create our own custom validation. Below are the steps to create custom Validation.

1. Create a custom Java class that implements interface Validator. The Class must contain a No-Argument constructor and a ‘validate’ method that override from the interface.

2. Register the Java class in faces-config.xml with unique ID

3. Use the ID in the validator tag in JSF page

4. Deploy and test the code

This section, we have described creating an ADF custom validator class that validates SSN. The validator is registered globally so that we could use it on any ADF pages.


1. Create Validator Java class

Expand the View Controller >> Right click on a package >> Click New >> Select Java

052716_0423_CreateOwnAD1 Create an ADF custom Validator - example


1. Input a Name ‘SSNValidator.’

2. Click theicon

3. Search for validator & Select the java.faces.Validator

4. Click Ok & Save all

052716_0423_CreateOwnAD2 Create an ADF custom Validator - example



The java class gets created. Open the class and Insert the validate method as shown below. The method processes the input text from the JSF page, parses it with the SSN pattern and error out if it not matches


2. Register the validator class in the faces-config.xml with unique ID

Please see the image below and follow the instruction

1. Double Click in the faces-config.xml

2. Click on the OverView tab

3. Click the Validators

4. Click the  icon

5. Input an ID ‘SSNValidator’ (You also use different ID, we’ll use it in our JSF code for validation)

6. Double click on the Textbox and Click the arrow mark. Click Edit.

7. Search for SSN and Select the ‘SSNValidator’ in the Edit property wizard (This is the Java class we created earlier)

8. Click Ok and Click Save

052716_0423_CreateOwnAD3 Create an ADF custom Validator - example

3. Use the ID in the JSF page

Open your JSF page where you want to insert the validation >> Click the Source tab and See the image below and follow the instruction

1. Select the validator. If validator tag does not exist then, drag and drop a validator from the component. Remove any binding property if exist

2. Click on the Validator Property

3. Choose the validator SSNValidator from the combo box

4. Insert an argument autoSubmit=true in the Input element as shown below. Click Save

052716_0423_CreateOwnAD4 Create an ADF custom Validator - example

4. Deploy and Test the Validator

Right click on the JSF page >> Click Run.The project got deployed on the WebLogic Server and the page will open on the server

Input a valid SSN in the text box you configured the validator and mouse out from it. No Error will get displayed

052716_0423_CreateOwnAD5 Create an ADF custom Validator - example

Input a wrong SSN and mouse out >> Error out and display the error message (The error message is what we mentioned in the Java code)

052716_0423_CreateOwnAD6 Create an ADF custom Validator - example

govindan Create an ADF custom Validator - example
Connect me


Thank you for visiting my personal blog. Myself Govindan, Software Developer by profession since 2006 and hence I started this blog early in 2016 and ever since I've been writing about technologies experienced and learnings of everyday life.

The views expressed on this blog are my personal views and do not necessarily reflect the views of my employer.

Please feeling free to reach me on any comments and feedbacks you have. Would be more than glad to listen and reply šŸ™‚
govindan Create an ADF custom Validator - example
Connect me
By | 2016-12-28T23:05:11+00:00 May 26th, 2016|Categories: ADF|Tags: , , , , |2 Comments
  • Raga

    I have a doubt in showing error messages after validation.
    For invalid data we will show error message as shown in your image, but it will display only when we place the focus on the corresponding field rather it should display once the field becomes invalid on tab action. It should display the error message constantly until we make it valid. Can you please suggest how can we do this?

  • Thej Kiran

    Hello Govind, I jsut came across your blog and felt very helping. I’m a newbie for ADF.
    Could you please post or share info on how to create server side validations (usually its called ajax validations).
    For eg.; email duplicate check. Error Message: “Email already exists!”

Like us on Facebook.