Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.4k views
in Technique[技术] by (71.8m points)

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

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...