After the upgrade to 5.2 RC I got the folliwing issue for the datatable which has a selection:
Please find attached my code:java.lang.UnsupportedOperationException: getRowData(String rowKey) must be implemented when basic rowKey algorithm is not used.
XHTML Page
Code: Select all
<p:dataTable id="jobListDatatable"
value="#{jobRequestController.lazyModel}" var="job"
rowKey="#{job.id}" widgetVar="jobTable"
filteredValue="#{jobRequestController.filteredJob}"
selection="#{jobListController.selectedJobList}" rows="10"
pageLinks="10" paginatorPosition="bottom" lazy="true"
paginator="true" resizableColumns="true"
currentPageReportTemplate="(Eintrag: {startRecord}-{endRecord} von {totalRecords}, Seite: {currentPage} von {totalPages})"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="10,20,50,100" paginatorAlwaysVisible="false"
emptyMessage="Keine Job gefunden">
<f:facet name="header">
<p:outputPanel style="float:left;">
<p:commandButton value="Job anlegen"
action="#{jobListController.doAddJob}" icon="fa fa-floppy-o"
styleClass="btn-success" style="text-align:left" />
<p:commandButton ajax="true" process="@all" style="float:right"
disabled="#{jobListController.selectedJobList.size() != 1}"
icon="fa fa-files-o" styleClass="btn-success" title="Kopieren"
onclick="PF('dlgCopyJob').show()" />
<h:outputText value=" " />
<p:commandButton onclick="PF('deleteJobDialog').show()"
style="float:right" styleClass="btn-danger"
disabled="#{jobListController.selectedJobList.size() != 1}"
icon="fa fa-trash-o" title="Löschen"
actionListener="#{jobListController.doDeleteJob(job)}" />
<h:outputText value=" " />
<p:commandButton id="toggler" type="button" style="float:right"
icon="fa fa-ellipsis-h" styleClass="btn-warning" />
<p:columnToggler datasource="jobListDatatable" trigger="toggler" />
</p:outputPanel>
<p:outputPanel style="text-align: right;">
<p:inputText id="globalFilter" onkeyup="PF('jobTable').filter()"
style="width:200px" />
<p:watermark for="globalFilter" value="Suche..." />
<h:outputText value=" " />
<p:commandButton ajax="true" styleClass="btn-info"
title="#{msg['general.button.extendedSearch']}"
icon="fa fa-search-plus" update=":jobListForm"
actionListener="#{jobRequestController.doShowExtendedSearch}" />
</p:outputPanel>
</f:facet>
<p:ajax event="rowSelect" update="jobListDatatable" />
<p:ajax event="rowUnselect" update="jobListDatatable" />
<p:ajax event="rowSelectCheckbox" update="jobListDatatable" />
<p:ajax event="rowUnselectCheckbox" update="jobListDatatable" />
<p:column selectionMode="multiple" toggleable="false"
style="width: 35px; text-align: center;" />
<p:column sortBy="#{job.jobName}" filterBy="#{job.jobName}"
filterStyle="display:none">
<f:facet name="header">
<h:outputText value="Name" />
</f:facet>
<p:commandLink
action="#{jobListController.redirectToOverviewPage(job)}"
ajax="false" style="margin-right:20px;">
<h:outputText value="#{job.jobName}" />
</p:commandLink>
</p:column>
</p:dataTable>
Bean
Code: Select all
@ViewScoped
@Named
public class JobRequestController extends ListDataModel<Job> implements
SelectableDataModel<Job>, Serializable {
private static final long serialVersionUID = 2815796004558360299L;
private static final Logger LOGGER = LoggerFactory
.getLogger(JobRequestController.class);
@Inject
private LoginBean loginBean;
@RequestScoped
private List<Job> filteredJob;
private LazyDataModel<Job> lazyModel;
@SuppressWarnings("serial")
@PostConstruct
public void findAllJobByUserId()
throws SearchRememberNotFoundException {
lazyModel = null;
if (lazyModel == null) {
lazyModel = new LazyDataModel<Job>() {
@Override
public List<Job> load(int startingAt, int maxPerPage,
String sortField, SortOrder sortOrder,
Map<String, Object> filters) {
Long loginUserId = loginBean.getCurrentUser()
.getId();
List<Job> list = null;
try {
list = jobService.findAllJobLazyLoading(
loginMandatoryId, startingAt, maxPerPage,
sortField, sortOrder, filters);
lazyModel.setRowCount(list.size());
} catch (JobNotFoundException e) {
lazyModel.setRowCount(0);
} catch (NullPointerException e) {
lazyModel.setRowCount(0);
}
return list;
}
};
}
}
@Override
public Job getRowData(String rowKey) {
List<Job> jobs = (List<Job>) getWrappedData();
for (Job job : jobs) {
if (job.getId().equals(rowKey))
return job;
}
return null;
}
@Override
public Object getRowKey(Job job) {
return job.getId();
}
@ViewScoped
@Named
public class JobListController implements Serializable {
private List<Job> selectedJobList;
// getter + setter
Entity:
Code: Select all
....
@Entity
@Table(name = "job")
public class Job implements Serializable {
.....
@Id
@GeneratedValue(generator = "job_id_seq", strategy = AUTO)
@SequenceGenerator(name = "job_id_seq", sequenceName = "job_job_id_seq", allocationSize = 1)
@Column(name = "job_id", nullable = false)
private Long id = NO_ID;
I saw there is also another user which has this problem:
http://forum.primefaces.org/viewtopic.php?f=3&t=41421
Thank you very much.
Best Regards