Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Cannot use a method in a groovy script as a default value

sgalaxyMar 23 2020 — edited Mar 23 2020

Hi,

(for learning purposes)

i' m trying to get a default value in a groovy script using a method. Specifically, using the emp table (of the SCOTT db user) i defined the entity and a simple view object on this table. After that, i declared a transient attribute , let's call it attrX which should take the value of the Sal attribute.

Also, i declared the public class empImpl which extends the EntityImpl class.

When i write the groovy expression in the attribute attrX:

Sal * 2

the ADF model tester runs as i'd want to. In the attrX column the salary is doubled.

But, when i call a method, for example getSal()   which is a method constructed automatically when i chose to configure the java implementation for

the object emp, an error occurs (see below).

I searched on the internet, trying to find out how to call a method defined in the entity object class in a groovy expression (as default value), and i found the

following ways:

adf.object.<method name>  or even source.<method name>.

source: https://www.oracle.com/technetwork/developer-tools/jdev/introduction-to-groovy-128837.pdf

So, i wrote adf.object.getSal()    or     source.getSal()

The error is : Exception in expression "model.entity.emp.attrX": oracle.jbo.script.ExprSecurityException when i run the adf model tester.

How should i write the expression calling this method?

Note:

I use Studio Edition Version 12.2.1.4.0

Thanks,

Sim

This post has been answered by Timo Hahn on Mar 23 2020
Jump to Answer
Comments
Post Details
Added on Mar 23 2020
2 comments
543 views