Oracle ADF Basics: Getting values of the multiselected rows in an af:table
In a former post I described how you could get access to the selected row in you af:table in your backing bean. This post takes it a step further and shows you how to deal with a multiselect table.
Let us first look at how to create a multi select table. Because this can't be done by drag-and-drop at once, you will first have to drop the view object on your page as a (read-only) table and then tick the checkbox for single selection in the af:table wizard, that is started and finish the wizard.
You can then go to source code of your page and edit the created tag manually from:
af:tableSelectOne
to:
af:tableSelectMany
After doing that you select the 'af:table' component in your 'structure pane' and clear the properties 'SelectionListener' and 'SelectionState (These properties refer to listeners that will only work on the last selected row and not all the selected rows). Now we are working in the property palette anyway we can also fill in the 'Bind' property so we bind the 'af:table' component to a backing bean, like this:
That's all it takes to create a multiselect table and make it available to your code!
To get access to the selected rows in the table, in this example, you will have to use in your backing bean:
-
// Get the (Oracle.jbo)keys of the rows that are selected in the table
-
this.getMyTable().getSelectionState().getKeySet();
-
-
// To clear the selected checkboxes:
-
this.getMyTable().getSelectionState().clear();
or in a JSF EL expression:
-
#{backing_multiselecttable.myTable.selectionState.keySet}
The latter is very handy if you create a method in your ApplicationModule, which has as a parameter a Set (containing Oracle Keys), like the following example, which will delete the rows that belong to the incoming set of primary keys:
After publishing this method in your Application Module by putting it in your 'Client Interface':
you can drag and drop it on your page with the multi select table as a button and set the parameter value to the selected rows in the af:table, like this:
![]()
I guess this shows it is rather easy to use the multiple select table. You only have to make sure the underlying view object of the 'af:table' component has at least one 'Key Attribute' defined. If not, the Set with keys will contain Integer values referring to the number the selected row has in the 'af:table' which isn't very usefull to select rows in a view object.
Tags: Oracle ADF










Hi ,
I have a question on this...
how to access the selected row data in the backing bean..
if the table has 3 columns how to access each column individually
@Naveen,
The easy (but rather ugly) way would be to add these three columns to the Key of the row. That way you can access the selected values directly in the KeySet in your backing bean.
An alernative would be to use the selected Key to get the complete row from the ViewObject and get the necessary values for each column, but that makes an extra roundtrip to the DB necessary.
Hope this helps.
Hi Pascal,
I am new to faces. could you please tell me how columns can be added to key..
In my scenario i am using a webservice data control for the table. I didnt create a view object..
Hi Naveen,
I haven't used this table component with a web service data control, so I don't know how that works. May be it is best to post your question at the OTN forum: http://forums.oracle.com/forums/forum.jspa?forumID=83
Sorry I can't help you with this.