Select All/Deselect All check box in a table is a common requirement. This can be implemented in multiple ways. In this blog, I will explain the steps, I used for one of my project.
Follow these steps:
- Add a transient attribute(say SelectDept) of type Boolean in the view object. Don't forget to set the updatable property to Always.
- Drag and drop the view object from the data control as an ADF Table
- Convert the SelectDept column to SelectBooleanCheckBox. Add command links to select/deselect check box in the header facet of this column.
- Call managed bean methods on click of the command link. After all these modifications the column code should look like:
- The bean methods onSelectAll, onDeselectAll in turn calls the method selectAllDept, deSelectAllDept respectively in AMImpl.java. It basically iterate through the RowSetIterator of DepartmentsView and set the value of SelectDept attribute, depending on the method being called.
UI Page:
Instead of command links (Select All/Deselect All), you can have a select boolean check box as well. On selecting it, all the check box are checked and un-selecting it will un-check all the check box in the table.
Sample Workspace:
Download the sample workspace from HERE.