Monday, December 28, 2015

ADF BC Groovy Improvements in ADF 12.2.1

Groovy scripting is improved in ADF 12.2.1. There are no inline Groovy expressions anymore. Expressions are saved in separate Groovy language file, external codesource. Each EO/VO will be assigned with separate file to keep Groovy expressions. This improves Groovy script maintenance (easier to check all Groovy expressions from EO/VO located in one file), also it improves runtime performance (as JDeveloper ADF code audit rule suggests).

Inline Groovy expressions created with previous JDeveloper versions are compatible in 12.2.1. All new expressions are created in separate *.bcs file. Sample application -, comes with validation rule implement in Groovy script expression:

We should check how validation rule definition looks in EO source. There is one inline Groovy expression I have created with previous JDeveloper version. It is marked as deprecated and suggested to be moved to external codebase:

Validation rule with Groovy expression created in JDeveloper 12.2.1 looks different. There is no inline Groovy code anymore, instead it points to the external codesource name:

Codesource name is registered inside operations definition:

I have defined two validation rules with Groovy for Jobs EO attributes MinSalary/MaxSalary. Code for both of them are included into single Jobs.bcs file:

On runtime it works correctly, entered values are validated against logic coded in Groovy:

Separate Groovy file approach can be turned off in ADF BC project settings, not recommended though:


Anonymous said...

Hi Andrejus,

it seems that some things don't work anymore if you move the expression to an external codesource (as JDeveloper 12.2.1 suggests).

For example - I use this expression to provide the value for a bind variable in a ViewObject's query by calling a method in the ApplicationModule (which works as expected):


As soon as I move it to the external codesource the application won't compile anymore:

Error(10,1): [Static type checking] - No such property: applicationModule for class: .ViewObjectImpl @ line 10, column 1. UsersVO.bcs MainModel.jpr

Do you have any idea why this is happening or is there another way to access the ApplicationModule in a bind variable's expression (that works with an external codesource) ?


Unknown said...


Check this link. It describes the cause of your problem:

Kiran Kumar said...

I am trying to initialise a variable using sequenceImpl groovy . But facing compilation errors.
Can u share an example using Sequence in Jdev 12.2.1

Unknown said...

Hi Jo in de Walvis,

I am coming across the same problem as Robert mentioned.I want to assign the application module method in bind variable of VO as default expression.As you suggested, I am modifying the trust Mode as "trusted". But i am getting the same error. It didn't resolve my issue. Any idea, is there any alternative approach to resolve this issue.


Naeem Qasim said...

viewObject and applicationModule keywords are no more accessible in adf12c and we are not seeing any workaround for this solution. Now we are unable to call view object function from bind variable in view object query. I request someone from oracle to reply because lots of community developers are facing these issue while migrating from 11g to 12c.

Andrej Baranovskij said...

Dont use external Groovy files, then it works in 12c to call applicationModule and viewObject keyword.