- Drag and drop method return from Data Control Pallete in JDeveloper, and from pop-up window choose to create ADF Read-only Table. In my sample I'm using method return for Departments;
- In Edit Table Columns dialog select 'Enable selection' check-box. Press OK;
- Single-selection table in JSPX page is created;
- Using right mouse button, click on af:table element in Structure window and choose Properties;
- In Table Properties dialog select Formatting tab and instead 'Single Selection' choose 'Multiple Selection' for 'Include Selection Column' option. Press OK.
Ok, there is enough only five steps, to create multi-selection table, let's test it. When table is opened, first row is selected by default. Hm..., it is like in single-selection table.
If you do not care about first row selected by default, let's randomly select any three rows and press Select button:
After Select button is pressed, only row for 'Human Resources' becomes selected:
So, it seems something is not ok. I have decided to research more deeper and have created 'Action Method Binding' for Select button in Backing bean. This method retrieves keys for the selected rows and prints information contained in those rows.
When selectButton_action() method was implemented, I have tested created multi-selection table for the second time. I have selected three rows and pressed Select button, in JDeveloper Log window was displayed only one row (should be three):
07/02/17 12:01:32 Selected Department: Human Resources
So, finally we have found a problem - multi-selection is enabled, but it works like a single-selection. How to solve this? Thanks God, it is simple - there is one property we should remove for af:table component:
selectionState=
"#{bindings.findAllDepartments1.collectionModel.selectedRow}"
"#{bindings.findAllDepartments1.collectionModel.selectedRow}"
Yes, selectionState set to 'selectedRow' is not needed in multi-selection table - remove it. When this property is removed, multi-selection feature works fine. Output in JDeveloper Log window, when three rows are selected:
07/02/17 12:09:39 Selected Department: Human Resources
07/02/17 12:09:39 Selected Department: IT
07/02/17 12:09:39 Selected Department: Executive
07/02/17 12:09:39 Selected Department: IT
07/02/17 12:09:39 Selected Department: Executive
Download developed sample - MultiSelection.zip. Model layer for this sample is developed using Oracle TopLink, standard HR schema DEPARTMENTS table is used. View layer is implemented using Oracle ADF Faces. Sample contains one JSPX page - multiSelection.jspx, where described multi-selection table functionality is implemented.
0 comments:
Post a Comment