Monday, June 22, 2015

ADF -Total Sum of a Column in a Table using Groovy:

In this blog we will see how to get a sum of column in table.

For Example:Sum of salary in employee table:

So,we will use Groovy for this task:

Model Project:

-create EmployeeVO based on Employee EO Table.

-go to EmployeeVO, create one transient attribute say TotalSalSum




-go to accessors,create view accessor of EmployeeVO
Shuffle EmployeeVO,following screen will appear:


-Then give the Groovy for TotalSalSum as follows:
EmployeeVO1.sum(“Salary”)




-Create a new page. Drag and Drop EmployeesVO from data control and create a new read only table "without" TotalSalSum Attribute.
-Now go to the Salary Column, add Facet-column ->footer



-Now from data control drag and drop TotalSalSum attribute in Salary attribute footer


-Go to the source of TotalSalSum ->  change output text value Attribute
From : <af:outputText value="#{row.TotalSalSum}"
To:  <af:outputText value="#{bindings.TotalSalSum.inputValue}"


-Now go to bindings and create a new binding for this attribute.



Save all and run Page:Result:





No comments:

Post a Comment