Validation in ADF Application (Using Groovy Expression)

Validation in ADF Application (Using Groovy Expression)

ADF support Groovy scripting language, allowing groovy expression to be used in attribute validation. So in this tutorial I will add same validation previously (Validation in ADF Application (Using EntityImpl’s Method)) using java Method but this time Groovy Script.

  1. Select Salary Attribute in Employees entity and go to validation tab.
  2. Then click on “Green Plus” icon to add new validation rule on attribute.
  3. On Dialog window select type to “Script Expression”, and write groovy expression to validate salary as following image.
     

    if("AD_PRES"==JobId)
    {
    return newValue>=50000
    }
    else
    {
    return newValue>=10000
    }
    
  4.    Set Error message for Salary.

newValue return value the user has just input. So expression return true if input salary greater than or equal to 50000 in case of “AD_PRES”. And no error message display to users. If user enter salary less than 50000 error message will popup. For other JobId Value must be greater than or equal to 10000.

Sample Code

About Manish Pandey

Manish is a Project Leader at Jagran Prakashan Ltd, focused on Jdeveloper Fusion Web Application(specifically Oracle ADF). He shares his knowledge through the OTN Jdev/ADF Forum. He has written more than 50 article about Oracle ADF and Jdeveloper.

Leave a Reply