ADF – Groovy for Total Sum of a Column in a Table

ADF – Groovy for Total Sum of a Column in a Table

We will be looking in this article as how we can add Total of a column in a table. Very often we require to have total of a column in a table. For example , we might need total sum of Salary column in the table.
We will be leveraging power of Groovy in accomplishing this task.
So lets see how we can do this.
Use Case :- Add a Total Salary Attribute below Salary column in Employees Table.
Model Project
Considering that we have EmployeesView VO object which is based on Employees EO, go to attributes of VO and click add new attribute. Select “Add new Attribute”. It will by default be transient. Give this attribute  name as TotalSal.
Now go to View Accessors tab and click on green + sign to create new View Accessor.
Select EmployeesView from the first window and shuttle it so that you can see like below.
Do ok and it should be like below screenshot.
Now go to attributes tab and select the new transient attribute (TotalSal).
Give its Default value as Expression and give Groovy expression as EmployeesView1.sum(“Salary”) .
View Project
Create a new page. Drag and Drop EmployeesVO from data control and create a new read only table “without” TotalSal Attribute.
Now go to Salary Column in Structure and do a right click and select footer from facet as shown below.
Now from EmployeesView1 in DataControl, drag and drop TotalSal column in this new footer facet.
Now go to bindings and create a new binding for this variable.
 And change the value of footer output text with this binding.
Save all and run this page.
Hope this was useful.
Happy Learning !!
Rohan Walia

Adding Serial No in the table in ADF-

Requirment- We want to show the Serial No as first column in table. Seems to be difficult.Not that much.

Solution- The first column of the table.Right click the first column in the structure window.Insert column using insert Before the af:column .
Then in newly created column insert outputText using right click and insert inside the af:column –>outputText

Now in the table properties value of table is something #{bindings.rderLinesVO1.collectionModel} .Below value property there is property called
VarStatus- give value as “vs”

Now to go to the newly created outPutText property and in the value give as #{vs.index+1}. that it.

Now you can see your table as below…

Happy coding with Techartifact 🙂

Inserting blank row in table in ADF

Hi All,

Requirment – To create 5 or 10 blank row in adf table.User can enter value in all row and able to perform bulk save or other action.How to do that.

Well for that you need to write a custom method in AMImpl.java as below..

 
    public void insertDefaultRows(){
          ViewObjectImpl ioOrderLines = this.getViewObject1();
          ioOrderLines.executeEmptyRowSet();
          int noOfRows=5;
          oracle.jbo.server.ViewRowImpl emptyRow;
          for (int i=0; i < noOfRows;i++){
              emptyRow = (oracle.jbo.server.ViewRowImpl)ioOrderLines.createRow();
              emptyRow.setNewRowState(oracle.jbo.Row.STATUS_INITIALIZED);
              ioOrderLines.insertRow(emptyRow);
          }
      } 

After add to client interface of application module so that it can visible in data control.Go to application module –>go to java tab–>go to client
interface–>select your method from left to right.Open data control you will able to see your method.

Now you can call your method in two ways.

1. call in page binding using invoke action- Right click the jspx or jsff and go to page defintion .go to executable –insert inside the executable
–>invoke action. Provide the ID and select your method from drop down.Make refresh condition as always.

2. Open the jsff .drag drop the custom method from data control and paste as button on the page.When you click the button it will show the blank row.

happy coding with Techartifact.