当我在dataTable中使用clik时,我的onRowSelect方法中的参数selectEvent为null,任何想法为什么???
form.xhtml文件:
<h:form>
<p:dataTable var="row"
value="#{backingBean.model}"
lazy="true"
rows="#{backingBean.model.getTablePageSize()}"
rowKey="#{row.id}"
rowsPerPageTemplate="#{loggedUserBean.getPageSizes()}"
paginator="true" paginatorPosition="bottom"
paginatorTemplate="{PreviousPageLink} {CurrentPageReport} {NextPageLink} {RowsPerPageDropdown}"
selection="#{backingBean.model.selectedRow}"
selectionMode="single"
emptyMessage="#{commonProperties.dataTableEmptyMessage}"
emptyMessagePosition="center">
<f:facet name="header">
<h:outputText value="#{properties.title}"/>
</f:facet>
<p:ajax event="rowSelect"
listener="#{controller.onRowSelect(args)}">
</p:ajax>
控制器方法:
public void onRowSelect(SelectEvent event) {
Row row = (Row) event.getObject();
getBackingBean().getModel().setSelectedRow(row);
RequestContext.getCurrentInstance().execute("updateButtons();");
}
答案 0 :(得分:2)
您在xhtml中提供了不必要的参数。
<p:ajax event="rowSelect" listener="#{controller.onRowSelect(args)}">
</p:ajax>
它应该是这样的:
<p:ajax event="rowSelect" listener="#{controller.onRowSelect}">
</p:ajax>