Wednesday, November 4, 2009

Groovy Validation Hint in Oracle ADF 11g

There is one very powerful option for Groovy validation in Oracle ADF 11g. This option is somehow hidden from developers and quite often not used. I decided to blog about it, in order to put some light on it. This option is about how to get old and new values for edited attribute. Groovy provides two reserved keywords - oldValue and newValue, you can use those keywords while writing Groovy validation script.

Download sample application - This sample implements pretty simple validation rule, to demonstrate how you can use mentioned Groovy keywords:

Reserved keyword oldValue is used to implement validation logic:

Developer can specify token method expressions in validation failure message based on the same oldValue and newValue:

On runtime, if validation rule will fail, it will show current wrong value. If you will not use newValue, it will show currently in database stored value, which is not correct.


Grant Ronald said...

I wrote a paper on introduction to groovy

Hasim said...

I want validate email address using Groovy expression.

Renan Monteiro's Sharepoint said...

Hi friends!

The new link to Grant's paper is

Aldo InĂ¡cio da Silva said...

Hi Andrejus,

I'm getting an error using groovy expression on Error Message on JDeveloper12.

Compile Time Error: [Static type checking] - No such property: newValue for class:groovy.lang.Binding