Search This Blog

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.
         }
}  

No comments:

Post a Comment