I tried to select rows in a p:dataTable
, however it shows an error. After I added a value for the rowKey
attribute of p:dataTable
, the error rectified. I thus wonder what the actual use of the rowKey
attribute is.
Asked
Active
Viewed 1.9k times
8
![](../../users/profiles/1797006.webp)
Karl Richter
- 6,271
- 17
- 57
- 120
![](../../users/profiles/2709855.webp)
vijaya kumar
- 757
- 2
- 11
- 20
1 Answers
15
I quote PrimeFaces reference guide:
RowKey should be a unique identifier from your data model and used by datatable to find the selected rows. You can either define this key by using the rowKey attribute or by binding a data model which implements org.primefaces.model.SelectableDataModel.
So if your datatable is set by collection of beans, rowKey should be the attributte which uniquely represents that bean, e.g a property representing a primary key of a database.
![](../../users/profiles/1797006.webp)
Karl Richter
- 6,271
- 17
- 57
- 120
![](../../users/profiles/1934175.webp)
miroslav_mijajlovic
- 1,559
- 14
- 31