DATATABLE ROW SELECTION RADIO CHECKBOX
Implementing a table
that allows row selection either having a column of radio buttons or checkboxes
Working exactly like
this one. http://www.primefaces.org/showcase/ui/datatableRowSelectionRadioCheckbox.jsf
After good hours of
struggle and deep search, I found out that, to
use the feature as shown in this url, You must have Primefaces-4.0 or above.
I was using primefaces 3.5 I couldn't get it working.
Helpful
Threads I visited:
I visited many
threads, but finally the 2 below helped me to come to a conclusion that the
feature was still a major problem in the lower versions(3.5 and below).
Things that must be
done to have this datatable working.
-Make sure your Bean
implements selectableDataModel or include
the rowKey property in the datatable
definition.
-selection - (Getters and setters in the Bean.
If selection mode is multiple, set and get and array. If the selection mode is
single, set and get the object)
-selectionMode - (multiple/single)
-Include this line as one of your columns <p:column selectionMode="single/multiple but not both" style="width: 4%"/>. This is selection mode for radio or checkbox
-Don't include selectionMode in the Datatable definition (<p:datatable selectionMode=""/>) since this is selection mode for row selection. Reason: Row selection and radio/checkbox selection are not compatible and cannot be both enabled.
Do it like here http://www.primefaces.org/showcase/ui/datatableRowSelectionRadioCheckbox.jsf but make sure to add rowkey in <p:datatable ../>
-Include this line as one of your columns <p:column selectionMode="single/multiple but not both" style="width: 4%"/>. This is selection mode for radio or checkbox
-Don't include selectionMode in the Datatable definition (<p:datatable selectionMode=""/>) since this is selection mode for row selection. Reason: Row selection and radio/checkbox selection are not compatible and cannot be both enabled.
Do it like here http://www.primefaces.org/showcase/ui/datatableRowSelectionRadioCheckbox.jsf but make sure to add rowkey in <p:datatable ../>
I did an example and here is my code https://www.dropbox.com/home/spikes/PrimeFaces/DataTable%20RowSelection%20Radio%20Checkbox
Only me can access the code. Its in my Dropbox and it's protected.