Search code examples
primefacesdatatabledatamodel

DataModel must implement org.primefaces.model.SelectableDataModel


I was using dataTable to display list of Objects (Primefaces 3.0) with no issues. But when I switched to 3.1RC1, I got the error :

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

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

I am not able to decide which is the perfect solution. First solution looks simpler as it requires less code changes. But, I am not sure whether it is ideal solution. Request you to help me out in deciding on this. Thank you.


Solution

  • Add rowKey to resolve the issue as this requires very little change to existing sources