Tag Archives: selection

How to in Jdeveloper ADF–Single row table selection


Scenario:

How to enable single row table selection?

Solution:

This seems an obvious question but newbie’s miss to understand this and will find difficulties in fixing this.

So what exactly we do to make the selection happen and confirm that it points to the current row of the af:table.

first, make sure that you have the following entries added to the af:table component of your page

selectedRowKeys="{bindings.Customers.collectionModel.selectedRow}"
selectionListener="#{bindings.Customers.collectionModel.makeCurrent}"
rowSelection="single"

Note: Customers is the tree binding for the table in the page definition file.

So what these entries do?

selectedRowKeys – the state of the selection is stored in this property. This property identifies the current selected row in the collectionModel of the table.

selectionListener – this is a listener that corresponds to the selection of the row. we bind it to the makeCurrent method of the table bindings collectionModel

rowSelection – we make it single row selection.

Advertisements

How To in Jdeveloper ADF Tutorials – get the selected table rows


This is a useful handy code to get the selected rows for the table.

What it does:

  • Get handle to the table using the JSFUtils find component method with the table id passed as a parameter
  • Get the selectedRowKeys for the table
  • Iterate through the rowkeys
  • Get the rowkey from the iterator
  • Add the rowkeys into a list
  • return the list to the caller

This method takes the table id as the parameter


private List getSelectedList(String tableName) {
RichTable rt = (RichTable)JSFUtils.findComponentInRoot(tableName);
RowKeySet keySet = rt.getSelectedRowKeys();
Iterator iter = keySet.iterator();
iter = keySet.iterator();
List list = new ArrayList();
while (iter.hasNext()) {
list.add(iter.next());
}
return list;
}

Usage:

This method is used to check if any rows are selected for the particular table. The method returns the rowkeys of the rows selected if there are any rows selected for the table

select tab based on the commandlink


The example of the paneltab selection by clicking the af:commandlink example is here

The same use case can be achieved by passing a request parameter for the goLink like


<af:golink destination="/faces/index?dt=true">

and enable the panelTabbed showdetailitem accordingly..


<af:showdetailitem disclosed="#{param.dt eq 'true'}">

How to select entire row using checkbox


To select all the rows in a table design a page like

 

 

 

 

 

 

create a binding to the table, the valuechangelistener of the checkbox will have the following code


 

 

 

 

 

working example can be downloaded from

http://adfproject.googlecode.com/files/SelectAllRowsInATable.zip