Displaying Multiple Rows in ADF Page

In this exercise, we will learn to access multi records through checkox selection. 


Create an ADF  application 


Create an Application module and view the object EmpVo with below query

select * from xx_employee_info

Once view object created now its time to add Transient attribute to display a checkbox









Now select the checkbox for the transient attribute as shown in the below code snippet. 





Now create a page and drop this View object from data control on to the page as Table. 




Select row selection as Multiple Rows as shown in below code snippet. 




Add button in the panel accordion for the table  to print the checked records 




Create Binding for the table "enpTable"and create actionlistener event for the button










Write below code in manage bean


package tgr.oracle.apps.fnd.PranayMultiChkBox;

import java.util.Iterator;
import java.util.List;

import javax.faces.event.ActionEvent;

import oracle.adf.model.BindingContext;
import oracle.adf.model.binding.DCBindingContainer;
import oracle.adf.model.binding.DCIteratorBinding;
import oracle.adf.view.rich.component.rich.data.RichTable;

import oracle.jbo.Key;
import oracle.jbo.Row;
import oracle.jbo.RowSetIterator;

import org.apache.myfaces.trinidad.model.RowKeySet;

public class ManageBean {
    private RichTable empTable;

    public ManageBean() {
    }

    public void setEmpTable(RichTable empTable) {
        this.empTable = empTable;
    }

    public RichTable getEmpTable() {
        return empTable;
    }

    public void SelectMultiRowEvt(ActionEvent actionEvent) {
        // Add event code here...
        boolean di;
            RowKeySet selectedEmps = getEmpTable().getSelectedRowKeys();    
                    Iterator selectedEmpIter = selectedEmps.iterator();
                    DCBindingContainer bindings =
                                      (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
                    DCIteratorBinding empIter = bindings.findIteratorBinding("EmpVO1Iterator");
                    RowSetIterator empRSIter = empIter.getRowSetIterator();
                     while(selectedEmpIter.hasNext()){
                       Key key = (Key)((List)selectedEmpIter.next()).get(0);
                       Row currentRow = empRSIter.getRow(key);
                       
                System.out.println(currentRow.getAttribute("ViewAttr"));
                try {
                     di = (Boolean)currentRow.getAttribute("ViewAttr");
                   // System.out.println("Selected check box Employee Name "+currentRow.getAttribute("EmployeeName"));
                    System.out.println("value of di "+di);
                } catch (NullPointerException e) {
                    // TODO: Add catch code
                  System.out.println("inside null pointer issue");
                    di=false;
                }
                if (di==true)
                {
                        System.out.println("Selected check box Employee Name "+currentRow.getAttribute("EmployeeName")); 
                    }
               
                        System.out.println("outside value of di"+di);
                    
            }
    }
}


Run the page and use CTRL key to select the records and select box and then click on button 


Output can be seen on Console







Comments

Post a Comment

Popular posts from this blog

Sample HZ API's script to Create Contacts and Contact Points in Oracle

REST integration built-in OIC to read Large files with size more than 10MB