Search This Blog

Showing posts with label fetch multiple adf table rows selected. Show all posts
Showing posts with label fetch multiple adf table rows selected. Show all posts

Saturday, August 18, 2012

Alternate approach for multiple row select on an ADF table

Earlier post covered a similar topic of how to capture multiple row selection made in an ADF table.

The problem with the earlier approach is that user have to select a row and in order to select the second row and subsequently from there on, they have to hold the ctrl key and click on the row to select additinal rows.

Here in this post, I am going to detail on an alternate approach which would eventually provide access to the selected row but with more user adaptablility.

Select the VO (say "MyVO") that you plan to create a ADF table, add an additional column as "selectMany" as an transient variable. Make sure to check the attribute updatable always.

When we drag the VO to create an ADF table make sure to change the new transient variable type from outputtext to selectBoolenCheckBox.
(OR)
Update the Edit Attribute : select Many control hints -> Control Type to Boolean.

Make sure the value on the checkbox looks something like this value="#{row.bindings.selectMany.inputValue}"

FacesContext facesContext = FacesContext.getCurrentInstance();
DCBindingContainer bindings = (DCBindingContainer)getBindings();
DCIteratorBinding iter = bindings.findIteratorBinding("MyVO");
RowSetIterator rsi = iter.getViewObject().createRowSetIterator(null);

Row current;
while (rsi.hasNext()) {
         current = rsi.next();
         if (true == current.getAttribute("selectMany")) {
                 // this is the row that is selected in the UI.
         }
}  

Friday, August 17, 2012

Fetch all the rows selected from a UI Table in ADF

Following is an example to get all the rows selected from a UI table in ADF.

How do we enable multiple selections on a table ?

When you drag and drop a VO on to a page, user is presented with different options to represent the data from the VO. Choose the option of ADF table and select the option of "multiple rows" under "Row Selection" (Other options available are None, Single row)

If there is no backing bean or Managed bean enabled while creating the page then create binding for the table, how ?
-------------------------------------------------------------------------
Click on the table in the structure panel, Go to property inspector - > Advance -> Binding - > Choose Edit -> Create new managed bean & create new porperty as "table1".

Above action creates a getter  and setter method for the "table1" as below in the bean.

    private RichTable table1;
   
    public void setTable1(RichTable table) {
        this.table = table;
    }

    public RichTable getTable1() {
        return table;
    }

-------------------------------------------------------------------------