DataModel must implement org.primefaces.model.SelectableDataModel when selection is enabled

user1281029 picture user1281029 · May 9, 2012 · Viewed 48.1k times · Source

I was trying to implement one DataTable Editable with RowSelection enabled.

But it is throwing out an exception:

DataModel must implement org.primefaces.model.SelectableDataModel when selection is enabled.

I implemented the DataModel in both the object class and the managed bean class but the error is the same. Now only a blank table appears for me. Please help.

Answer

rags picture rags · May 9, 2012

There are two solutions for this problem:

  1. Adding rowKey, selection and selectionMode attributes to dataTable
  2. Implementing SelectableDataModel interface and extending a DataModel like ListDataModel for filling the dataTable

First one is Simpler. Adding rowKey="#{myEntity.carID}" to your p:dataTable should solve your problem