2 total views, 1 views today

ADF Client side validation – Email validation

ADF supports both server side and client side validation. Server side validation is where we write the validation code on the Java class, so when a user input data in the JSF page, the value will send to the server for validation and the server response back with the output. So a client – server call back will happen whenever a validation occurs.

In ADF client side validation we write the validation code on the JSF page, so when a user input data on the page, the JSF page validates the data and respond back. There is no request and response to & from the server, and it is very fast compared to the server side validation. Most of the time we try to put the validation logic in Client side for better performance.

In this section, I have described how to create a client side validation using the regular expression. I have a form in my the JSF page with an email field. Whenever user inputs an invalid email and moves out from the field, JSF throws an error message

Process

Open the JSF page which has email field >> Search for regular expression in components >> Drag and drop the Validate Regular Expression to the Email field as shown below

Click the Source tab of the JSF page >>Comment out the existing validator >> Select the ValidateRegExt tag >> click the tab Validate Regular Expression on the right side

Input a regular expression in the pattern >> Error message in the MessageDetailNoMatch as shown below >> Click Save

Pattern: ^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$

Message: You have entered an invalid email address. Please try again.

052616_0224_Clientsidev3 Client side validation in ADF pages – Email validation

Test the Project

Deploy the project in WebLogic. Input an invalid email in the Email field and mouse over from it. An error message will get displayed as shown below

052616_0224_Clientsidev4 Client side validation in ADF pages – Email validation

govindan Client side validation in ADF pages – Email validation
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 Client side validation in ADF pages – Email validation
Connect me
By | 2016-12-28T23:11:56+00:00 May 25th, 2016|Categories: ADF|Tags: , , , |3 Comments
  • Amritha Ramesh

    how can i avoid the “the format is incorrect” message, and show only the message that we have specified

    • Govindan Padmanaban

      There is no direct way to change the message title but we can accomplish by

      ADF Custom Error Message
      ————————————–

      1. Create a property file, Example

      Create a file MyMessageBundle.properties under a the java package

      2. Find the property of the validator from the below URL (Example: af:validateRegExp)

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

      3. Add the properties into the property file . Example:

      org.apache.myfaces.trinidad.validator.RegExpValidator.NO_MATCH=
      org.apache.myfaces.trinidad.validator.RegExpValidator.NO_MATCH_detail=

      4. Open faces-config.xml under WEB-INF , Click ‘Overview’ tab, Select ‘Application’, Add the property file with the package name in ‘Message Bundle’. Example

      com..MyMessageBundle.properties

  • Vidya Gondhale

    Thanq ,Very Helpful info with clarity.

Like us on Facebook.
Connect!