Thursday, February 7, 2013

ADF BC Groovy with Java Imports

ADF BC Groovy expressions support is really great and often saves a lot of time in development of complex functionalities. It comes very handy when retrieving referenced data or calling custom ADF BC methods. There is one more hidden gem offered by ADF BC Groovy - option to import Java packages directly into Groovy and use Java functionality.

Here is the example - I'm importing java.text.SimpleDateFormat directly from Groovy expression and then using Java formatting to retrieve month and year portion from current date. This expression is defined for default value of the transient attribute:


Simple and no headache - it just works:


Here you can download sample application for this post - AdvancedGroovyApp.zip.

5 comments:

Anonymous said...

thank you

Anonymous said...

Great discovery Andrejus, never would have thought of that. Can be very helpfull.

Thx.

Filip Huysmans

Andrejus Baranovskis said...

Sounds good Filip ! :)

Andrejus

MarioT said...

Hi! wonderful post. does this works on any jdev version ? we are not currently working with the last release. we are on 11.1.1.4

Andrejus Baranovskis said...

I think it should work with any version. But I was testing only with the latest JDev.

Andrejus