Home » ADF » ADF Table: Select multiple rows using check box.
ADF Table: Select multiple rows using check box.

ADF Table: Select multiple rows using check box.

Today I’m going to explain very common case of selecting multiple rows in ADF table using checkboxes. This is very common requirement where user wants to select multiple rows using check box. Here I’m using hr schema employees table.

 

Step1: create Entity Object and View Object using Employees table.

Step2: Create transient attribute Boolean type on Employees View Object.

4-05-3

Step3: Set Control Type to Checkbox on Control Hint tab.

4-05-4

Step4: Create jspx page and drag-drop as Adf table from data control. Set row selection to multiple.

4-05-5

Step5: Create Adf button with following code on ActionListener event method.

public void getSelectedRows(ActionEvent actionEvent) {

BindingContext bindingctx=BindingContext.getCurrent();

BindingContainer binding=bindingctx.getCurrentBindingsEntry();

DCBindingContainer bindingsImpl = (DCBindingContainer) binding;

DCIteratorBinding dciter = bindingsImpl.findIteratorBinding("EmployeesView1Iterator");

ViewObject vo=dciter.getViewObject();

Row rr=null;

int i=0;

int j=0;

boolean flag=false;

long rowc=vo.getEstimatedRowCount();

for(int f=1;f<=rowc;f++)

{

if(i==0)

{

rr=vo.first();

}

else

{

rr=vo.next();

}

i++;

 

flag=false;

if((rr.getAttribute("Mark")) != null)

{

flag= (Boolean)rr.getAttribute("Mark");

}

if (flag)

{

System.out.println("EmployeeId     Firstname            Salary");

System.out.println(rr.getAttribute("EmployeeId")+"             "+rr.getAttribute("FirstName")+"              "+rr.getAttribute("Salary"));

}

}

}

 

 

Output:

4-05-7

 

4-05-8

Sample Code

About Manish Pandey

Manish Pandey is a Senior Developer with more than 3 years of experience in JAVA Programming. Currently enhancing skills in ADF.

3 comments

  1. thank you…
    i like this page… :)

  2. hi manish. thanks for your great post. in your application data will print after pressing the button,but i want to insert selected roes into a table after pressing the button instead of printing. can you halp me with this problem?

    • Hi Jalal

      yes you can, you have to create row problematically in your View Object where you want to create.

      write following line of code to create row on view object where i have used System.out.println() .

      ViewObject insertobj =new ViewObject(“”);
      Row insertrow=insertobj.createRow();

      insertrow.setAttribute(“AttrName”,rr.getAttribute(“EmployeeId”);
      insertrow.setAttribute(“AttrName”,rr.getAttribute(“FirstName”));
      insertrow.setAttribute(“AttrName”,rr.getAttribute(“Salary”));
      insertobj.insertRow(insertrow);

      thanks
      Manish

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>