Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DataModel must implement org.primefaces.model.SelectableDataModel when selection is enabled, but I have already defined rowKey

I've a selectable PrimeFaces 3.4.1 datatable:

<p:dataTable value="#{projectAdminisrationMB.selectedUserMemberOfGroups}" var="group1" 
    rowKey="#{group1.name}" selectionMode="single" selection="#{projectAdminisrationMB.selectedBelongToGroup}">
    ...
</p:dataTable>

I'm getting this error:

com.sun.faces.context.PartialViewContextImpl$PhaseAwareVisitCallback visit Grave: javax.faces.FacesException: DataModel must implement org.primefaces.model.SelectableDataModel when selection is enabled.

But I have already set rowKey as per FacesException: DataModel must implement org.primefaces.model.SelectableDataModel when selection is enabled. How is this caused and how can I solve it?

like image 224
Amira Avatar asked Nov 12 '12 11:11

Amira


1 Answers

This can occur when the EL expression in the rowKey attribute ever evaluates null.

Make sure that the name property of your Group instance is never null. Otherwise better use a property representing the autogenerated DB primary key, such as #{group1.id} — if you have one.

like image 164
BalusC Avatar answered Nov 15 '22 08:11

BalusC