Using Groovy to read values from a different view object

原文: http://blogs.oracle.com/grantronald/entry/using_groovy_to_read_values

We recently posted an ADF Insider Essentials that showed how to build an LOV switcher. In this example, Frank Nimphius wrote a custom method into the PaymentTypeVOImpl which returns the string CASH or CREDIT depending on the lookup value passed in (1 or 2). This method is then called from the Orders view object via a Groovy expression.

However, there is an even quicker way without even having to create a custom method. To explain, I'm going to use the good old Employees and Jobs tables from the HR schema. Lets assume, that when you create a new employee their default role is AC_MGR (account manager) and their default salary should be the minimun salary for an accout manager. In this case, we'll actually read the minimum salary into the EmployeesVO.Salary field from the JobsVO.Min_Salary field.

1) First create default ADF BC based on Employees and Jobs

2) In the EmployeesVO add a view accessor to JobsVO (and call it JobsView). This "links up" the EmployeesVO to the JobsVO

3) Set the default EmployeesVO.JobId to AC_MGR

4) Set the default EmployeesVO.Salary to JobsView.findByKey(key(JobId),1)[0].MinSalary

So what does this Groovy expression do? It "walks" to the JobsVO using the JobsView accessor and then calls findByKey using the JobId. This returns an array and since we know JobId is unique we can just get the first entry's MinSalary.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值