How to customize ADF Validator Message

The ADF Validator components help to identify the error present in the data input by the user. When the validator finds an error in the input data, say an af:inputText component, the validator immediately display an error message in a small popup. The title and error details are pre-configured to each validator component. The same applies to ADF converter as well.

 

In the following example, detailed how to customize the ADF Validator Message.

ADF Validator Message without Customization

 

In my JSF page, I have an af:InputText component for email and I used a regular expression to validate the email. Look below the content with validator

 

Run the above will give the following output. Look at the title and error message

010517_0416_HowtoOverri1 How to customize ADF Validator Message

 

ADF Validator Message with Customization

As you see,  the above error message is not formatted well. Let’s customize the message by

Go to the properties of the validator >> Input a custom error message in the messageDetailNoMatch >> Input a hint if required

Note: I have used two parameters {0} and {1}. they are parameters of validateRegExp

 

010517_0416_HowtoOverri2 How to customize ADF Validator Message

 

Look at the modified Output below.

010517_0416_HowtoOverri3 How to customize ADF Validator Message

 

Customize ADF Validator Message at Application level

What if I want to change the error message at global level instead of doing it in each component. Follow the steps to override at application level.

1. Go to the below URL to find the supported properties & MessageKey.

http://docs.oracle.com/middleware/1221/adf/develop-faces/GUID-D3E0E6EC-7745-4E7B-BABF-DCE08582AC2A.htm#ADFUI806

 

2. Search for the validator ( example: af:validateRegExp ) you are using and find the message key. Here you can find the supported parameter as well.

010517_0416_HowtoOverri4 How to customize ADF Validator Message

 

3. Create a property file,
( example: MyMessageBundle.properties ) , and paste the message key and add title and message like below

010517_0416_HowtoOverri5 How to customize ADF Validator Message

 

4. Open the faces-config.xml under WEB-INF, Click on the Overview tab, Click Applications, Add the property file in the Message Bundle

010517_0416_HowtoOverri6 How to customize ADF Validator Message

 

5. Remove the messageDetailNoMatch property in the validator component if any because that has high precedence over property file. Run the page

010517_0416_HowtoOverri7 How to customize ADF Validator Message

 

Download Project: ADF Validator Custom Message

govindan How to customize ADF Validator Message
Connect me

Govind

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 How to customize ADF Validator Message
Connect me
By | 2017-01-04T23:35:14+00:00 January 4th, 2017|Categories: ADF|Tags: , , |0 Comments
Like us on Facebook.
Connect!