Saturday, January 31, 2015

CheckBox in ADF Table and retrieve selected rows

In this post I will explain a way to implement checkbox in the rows of ADF Table component. This is a generic approach and can also be used in other components but we will take example of table component for this post.

This is common requirement in many features e.g. Multiple Delete or assigning multiple things by selecting checkbox.

Lets dive into the implementation.

Created a simple ADF app with HR Schema using Departments Table. Created DepartmentsEO,VO and AM.

First since we need a checbox in every row of the Departments table, we need to add a transient attribute in DepartmentVO of Type Boolean. The value of this boolean (false or true) will render the checkbox as (checked or unchecked).

Remember to make this transient attribute "SelectRow" as Boolean and Always Update.

Now in the property inspector for this new transient attribute,  set control type as Check Box.

We are all set with the model part.

Now in the View Controller Project, Drag this DepartmentsVO on the page and create a read only table.

The important thing here is that it creates and outputText for selectrow column also. So delete the output text in Select Row colum and again from the data control, drag the selectrow attribute under the selectrow column of the table and select selectBooleanCheckbox.

So the table should look like below:

Now just added a button process, this button calls a method in the bean and there we get values of all the selected rows. Below is the code from the actionListener of process button.

We are all good. Just run the page as below.

We can see that every row has a checkbox. Now select some checkboxes and click on process button.

We selected Marketing , Human Resources and IT. Lets see what happens on clicking Process button in our action listener.

So we get handle of all the rows which were selected in the table !

Thats it.

Application Can be downloaded at CheckBoxInTableApp



  1. How to validate is at least one check box is selected, before opening a popup

  2. How to validate is at least one check box is selected, before opening a popup

  3. Hi,

    When I select any chk box first time below code returns null.
    Row[] selectedRow = vo.getFilteredRows("Selected" , true);
    When i select 2nd time,it gives the correct result.

    can u suggest smthng

  4. Hi,

    My requirement is as soon as a select a checkbox that row should get inserted into a data object and if i remove the selection then it should delete it from the data object. This should happen for multiple rows also. How can i do that

  5. When I query first time
    Row[] selectedRows = vo.getFilteredRows("RowSelector", true);
    it takes huge time approx 160 sec and on second process, time of exec is less than a couple of second. Is any cache related issue ?
    Querying on selecting 2-3 rows every time

  6. Thank you so much. I was actually looking for something a little different but change my view to match your idea after reading this article.

  7. How to set check box value to false from bean ??