If there is a condition in which you have to calculate the sumtotal of a VO field in ADF (like if you want to calculate the sum of salary of all the employees of a Department) , then better of all option is to use groovy expression to calculate the sum.
Here is an application which is used to calculate the sum of salary of all the employees of a given department.
- Create a new ADF application and create database connection with HR Schema. Generate the Business components. Here am using two tables ie Employee and Departments.
- Now create a ViewLink between Department and Employee using DepartmentId as foreign key.
- Use the Accessor to get the salary from the employee table to department table.
- Then create a transient variable in the DepartmentVO, and then assign value to it using the expression
EmpVO.sum("SalTot"); - Here is an screen shot. The name 'EmpVO' is the name of the Accessor of the Employee table in the deptToEmpViewLink.
- Then run the AM to see the Application.
- You can find the ADF application at Groovy.rar
No comments:
Post a Comment