我有以下代码:
<h:form enctype="multipart/form-data">
<p:dataTable
var="report"
value="#{businessDomain.value.reportEntities}"
style="padding:0px; margin:0px; border:0px;"
filteredValue="#{businessDomain.value.filteredReportEntities}"
scrollable="true" scrollHeight="200" paginator="false" rows="999"
rowKey="#{report.id}" rowIndexVar="rowIndex" selection="#{reportController.entity}" selectionMode="single">
<p:ajax event="rowSelect" listener="#{reportController.onRowSelect}" update="@(form)"/>
<p:column name="name" filterBy="#{report.name}" filterMatchMode="contains">
<tp:outputText object="#{report}"/>
<h:outputText value=" (#{myWithFailedStatusI18nCategoryModel.i18nCodeMap[report.status]})" rendered="#{report.status != 'A'}"/>
</p:column>
<p:column name="button" style="width:20px;">
<p:commandButton update="@(form)" action="#{controller.getPathToDetailForm}"
icon="ui-icon-wrench" styleClass="tpTableButton"
rendered="#{reportController.isEntityUpdateable and organizationController.authenticatedUserOrganization.id == report.organization.id}">
<f:setPropertyActionListener target="#{reportController.entity}" value="#{report}"/>
</p:commandButton>
</p:column>
</p:dataTable>
</h:form>
在该视图的控制器中,我有一个类(在值businessDomain.value的后面):
public class ReportCategory{
...
private List<ReportEntity> reportEntities;
private List<ReportEntity> filteredReportEntities;
...
public List<ReportEntity> getReportEntities() {
return reportEntities;
}
public List<ReportEntity> getFilteredReportEntities() {
getLogger().info("getFilter called")
return filteredReportEntities;
}
public void setFilteredReportEntities(List<ReportEntity> filteredReportEntities) {
getLogger().info("setFilter called: "+filteredReportEntities);
this.filteredReportEntities = filteredReportEntities;
}
}
不过滤所有内容的初始格式就可以了。.实体以正确的方式显示。但是,如果我在过滤器中键入内容,则会得到一个getFilter和setFilter调用..其中setFilter参数值始终为null:
getFilter called
setFilter called: null
我一直遵循素数示例https://www.primefaces.org/showcase/ui/data/datatable/filter.xhtml
(我使用的是Primefaces 5.3.14) 我发现了这个问题,但由于我没有太大帮助 filterValue for a dataTable in Primefaces 5.3 always null