最近,我已经从JSF 2.0迁移到JSF 2.2和Primefaces 3.5到Primefaces 5
我有一张表,每列都有过滤器。使用primefaces 3.5
进行过滤效果很好<p:dataTable id="gwsReportAllPartListDataTable"
value="#{viewAllAnalyticsBean.gwsReportPartTwoList}"
var="report"
paginator="true"
rows="100"
paginatorTemplate="{PageLinks} {CurrentPageReport}"
currentPageReportTemplate="{currentPage} #{dictionary['out_of']} {totalPages}"
emptyMessage="#{dictionary['nothing_is_here']}"
scrollable="true"
scrollWidth="1221"
scrollHeight="500">
<p:ajax event="filter" listener="#{viewAllAnalyticsBean.onFilterDataTable}" oncomplete="updateFilters()"/>
<p:column styleClass="columnCustomClass" style="width: 90px;position:relative; padding-bottom: 30px;">
<f:facet name="header">
<h:outputText value="#{dictionary['reporting_period']}" />
</f:facet>
<h:outputText value="#{report.gwsReportPartOne.year}, #{report.gwsReportPartOne.quarter}"/>
</p:column>
<p:column styleClass="columnCustomClass" style="width: 90px;position:relative; padding-bottom: 30px;" filterBy="#{report.gwsReportPartOne.contractNumber}" filterMatchMode="contains" filterStyle="width:80px; position:absolute; bottom:4px;" filterValue="">
<f:facet name="header">
<h:outputText value="#{dictionary['subsoil_user_contract_register_number']}" />
</f:facet>
<h:outputText value="#{report.gwsReportPartOne.contractNumber}"/>
</p:column>
<p:column styleClass="columnCustomClass" style="width: 40px;position:relative; padding-bottom: 30px;" filterBy="#{report.gwsReportPartOne.gwsType.code}" filterMatchMode="contains" filterStyle="width:30px; position:absolute; bottom:4px;">
<f:facet name="header">
<h:outputText value="#{dictionary['gws_type']}" />
</f:facet>
<h:outputText value="#{report.gwsReportPartOne.gwsType.code}" />
</p:column>
<p:column id="tender_code" width="100" style="position:relative; padding-bottom: 30px;" styleClass="columnCustomClass" filterBy="#{report.skp.code}" filterMatchMode="contains" filterStyle="width:90px; position:absolute; bottom:4px;">
<f:facet name="header">
<h:outputText value="#{dictionary['gws_code_by_skp']}" />
</f:facet>
<h:outputText value="#{report.skp.code}"/>
</p:column>
<p:column styleClass="columnCustomClass" style="width: 150px; position:relative; padding-bottom: 30px;" filterBy="#{report.description}" filterMatchMode="contains" filterStyle="width:140px; position:absolute; bottom:4px;">
<f:facet name="header">
<h:outputText value="#{dictionary['item_name_and_short_description_of_purchased_gws']}" />
</f:facet>
<h:outputText value="#{report.description}" />
</p:column>
<p:column styleClass="columnCustomClass" style="width: 50px; position:relative; padding-bottom: 30px;" filterBy="#{report.gwsReportPartOne.tenderType.code}" filterMatchMode="contains" filterStyle="width:40px; position:absolute; bottom:4px;">
<f:facet name="header">
<h:outputText value="#{dictionary['purchase_way']}" />
</f:facet>
<h:outputText value="#{report.gwsReportPartOne.tenderType.code}" />
</p:column>
<p:column styleClass="columnCustomClass" style="width: 80px; position:relative; padding-bottom: 30px;" filterBy="#{report.gwsReportPartOne.agreementNumber}" filterMatchMode="contains" filterStyle="width:70px; position:absolute; bottom:4px;">
<f:facet name="header">
<h:outputText value="#{dictionary['agreement_number']}" />
</f:facet>
<h:outputText value="#{report.gwsReportPartOne.agreementNumber}" />
</p:column>
<p:column styleClass="columnCustomClass" style="width: 80px; position:relative; padding-bottom: 30px;" filterBy="#{report.gwsReportPartOne.resultDate}" filterMatchMode="contains" filterStyle="width:70px; position:absolute; bottom:4px;">
<f:facet name="header">
<h:outputText value="#{dictionary['tender_result_date']}" />
</f:facet>
<h:outputText value="#{report.gwsReportPartOne.resultDate}" >
<f:convertDateTime pattern="dd.MM.yyyy"/>
</h:outputText>
</p:column>
<p:column styleClass="columnCustomClass" style="width: 80px; position:relative; padding-bottom: 30px;" filterBy="#{report.gwsReportPartOne.agreementStartDate}" filterMatchMode="contains" filterStyle="width:70px; position:absolute; bottom:4px;">
<f:facet name="header">
<h:outputText value="#{dictionary['agreement_conclusion_date']}" />
</f:facet>
<h:outputText value="#{report.gwsReportPartOne.agreementStartDate}" >
<f:convertDateTime pattern="dd.MM.yyyy"/>
</h:outputText>
</p:column>
<p:column styleClass="columnCustomClass" style="width: 80px; position:relative; padding-bottom: 30px;" filterBy="#{report.gwsReportPartOne.agreementEndDate}" filterMatchMode="contains" filterStyle="width:70px; position:absolute; bottom:4px;">
<f:facet name="header">
<h:outputText value="#{dictionary['agreement_deadline_date']}" />
</f:facet>
<h:outputText value="#{report.gwsReportPartOne.agreementEndDate}" >
<f:convertDateTime pattern="dd.MM.yyyy"/>
</h:outputText>
</p:column>
<p:column styleClass="columnCustomClass" style="width: 50px; position:relative; padding-bottom: 30px;" filterBy="#{report.gwsReportPartOne.agreementStatus.code}" filterMatchMode="contains" filterStyle="width:40px; position:absolute; bottom:4px;">
<f:facet name="header">
<h:outputText value="#{dictionary['agreement_status']}" />
</f:facet>
<h:outputText value="#{report.gwsReportPartOne.agreementStatus.code}" />
</p:column>
<p:column styleClass="columnCustomClass" style="width: 80px; position:relative; padding-bottom: 30px;" filterBy="#{report.gwsReportPartOne.agreementSum}" filterMatchMode="contains" filterStyle="width:70px; position:absolute; bottom:4px;">
<f:facet name="header">
<h:outputText value="#{dictionary['total_sum_of_agreement_without_vat']}, #{viewAllAnalyticsBean.getThTengeOrUsd()}" />
</f:facet>
<h:outputText value="#{viewAllAnalyticsBean.convertValueToCurrentCurrency(report.gwsReportPartOne.agreementSum)}">
<f:convertNumber pattern="0.00#" locale="ru-RU"/>
</h:outputText>
</p:column>
<p:column styleClass="columnCustomClass" style="width: 80px; position:relative; padding-bottom: 30px;" filterBy="#{report.gwsReportPartOne.plannedSum}" filterMatchMode="contains" filterStyle="width:70px; position:absolute; bottom:4px;">
<f:facet name="header">
<h:outputText value="#{dictionary['planned_sum_in_gpz_without_vat']}, #{viewAllAnalyticsBean.getThTengeOrUsd()}" />
</f:facet>
<h:outputText value="#{viewAllAnalyticsBean.convertValueToCurrentCurrency(report.gwsReportPartOne.plannedSum)}" >
<f:convertNumber pattern="0.00#" locale="ru-RU"/>
</h:outputText>
</p:column>
<p:column styleClass="columnCustomClass" style="width: 80px; position:relative; padding-bottom: 30px;" filterBy="#{report.gwsReportPartOne.actuallyPaidSum}" filterMatchMode="contains" filterStyle="width:70px; position:absolute; bottom:4px;">
<f:facet name="header">
<h:outputText value="#{dictionary['actually_paid_sum_for_report_period_of_agreement_without_vat']}, #{viewAllAnalyticsBean.getThTengeOrUsd()}" />
</f:facet>
<h:outputText value="#{viewAllAnalyticsBean.convertValueToCurrentCurrency(report.gwsReportPartOne.actuallyPaidSum)}" >
<f:convertNumber pattern="0.00#" locale="ru-RU"/>
</h:outputText>
</p:column>
<p:column styleClass="columnCustomClass" style="width: 100px; position:relative; padding-bottom: 30px; background-color: #{two.gwsSumWithoutVatColor}" filterBy="#{report.gwsSumWithoutVat}" filterMatchMode="contains" filterStyle="width:90px; position:absolute; bottom:4px;">
<f:facet name="header">
<h:outputText value="#{dictionary['tender_volume_without_vat_in_price']}, #{viewAllAnalyticsBean.getThTengeOrUsd()}" />
</f:facet>
<h:outputText value="#{viewAllAnalyticsBean.convertValueToCurrentCurrency(report.gwsSumWithoutVat)}">
<f:convertNumber pattern="0.00#" locale="ru-RU"/>
</h:outputText>
</p:column>
<p:column styleClass="columnCustomClass" style="width: 80px; position:relative; padding-bottom: 30px;" filterBy="#{report.gwsReportPartOne.supplierBinOrIin}" filterMatchMode="contains" filterStyle="width:70px; position:absolute; bottom:4px;">
<f:facet name="header">
<h:outputText value="#{dictionary['supplier_bin_iin']}" />
</f:facet>
<h:outputText value="#{report.gwsReportPartOne.supplierBinOrIin}" />
</p:column>
<p:column styleClass="columnCustomClass" style="width: 150px; position:relative; padding-bottom: 30px;" filterBy="#{report.gwsReportPartOne.supplierName}" filterMatchMode="contains" filterStyle="width:140px; position:absolute; bottom:4px;">
<f:facet name="header">
<h:outputText value="#{dictionary['supplier_gws_name']}" />
</f:facet>
<h:outputText value="#{report.gwsReportPartOne.supplierName}" />
</p:column>
<p:column styleClass="columnCustomClass" style="width: 60px; position:relative; padding-bottom: 30px;" filterBy="#{report.gwsReportPartOne.supplierCountry.code}" filterMatchMode="contains" filterStyle="width:50px; position:absolute; bottom:4px;">
<f:facet name="header">
<h:outputText value="#{dictionary['supplier_gws_country']}" />
</f:facet>
<h:outputText value="#{report.gwsReportPartOne.supplierCountry.code}" />
</p:column>
<p:column styleClass="columnCustomClass" style="width: 80px; position:relative; padding-bottom: 30px;" filterBy="#{report.kazcontent}" filterMatchMode="contains" filterStyle="width:70px; position:absolute; bottom:4px;">
<f:facet name="header">
<h:outputText value="#{dictionary['local_content_piece']}, %" />
</f:facet>
<h:outputText value="#{report.kazcontent}" >
<f:convertNumber pattern="0.00#" locale="ru-RU"/>
</h:outputText>
<ui:remove><h:outputText value="#{report.kazcontentInService}" >
<f:convertNumber pattern="0.00#" locale="ru-RU"/>
</h:outputText></ui:remove>
</p:column>
<p:column styleClass="columnCustomClass" style="width: 80px; position:relative; padding-bottom: 30px;" filterBy="#{report.procurementSumOfLocalContentOfGws}" filterMatchMode="contains" filterStyle="width:70px; position:absolute; bottom:4px;">
<f:facet name="header">
<h:outputText value="#{dictionary['procurement_sum_of_local_content_of_tru']}, #{viewAllAnalyticsBean.getThTengeOrUsd()}" />
</f:facet>
<h:outputText value="#{viewAllAnalyticsBean.convertValueToCurrentCurrency(report.procurementSumOfLocalContentOfGws)}" >
<f:convertNumber pattern="0.00#" locale="ru-RU"/>
</h:outputText>
</p:column>
<p:columnGroup type="footer">
<p:row>
<p:column footerText="#{dictionary['totals']}: " style="text-align:right"/>
<p:column footerText="" />
<p:column footerText="" />
<p:column footerText="" />
<p:column footerText="" />
<p:column footerText="" />
<p:column footerText="" />
<p:column footerText="" />
<p:column footerText="" />
<p:column footerText="" />
<p:column footerText="" />
<p:column footerText="#{viewAllAnalyticsBean.totalAgreementSum}" />
<p:column footerText="#{viewAllAnalyticsBean.totalPlannedSum}" />
<p:column footerText="#{viewAllAnalyticsBean.totalActualPaid}" />
<p:column footerText="#{viewAllAnalyticsBean.totalGwsSum}" />
<p:column footerText="" />
<p:column footerText="" />
<p:column footerText="" />
<p:column footerText="#{viewAllAnalyticsBean.averageKazContent} %" />
<p:column footerText="#{viewAllAnalyticsBean.totalGwsLocalContent}" />
</p:row>
</p:columnGroup>
</p:dataTable>
我有onFilterDataTable函数,每次用户开始输入时都会触发,以过滤每列上的字段。
public void onFilterDataTable(AjaxBehaviorEvent event) {
System.out.println("Filter called");
DataTable table = (DataTable) event.getSource();
filteredGwsReportPartTwoList = table.getFilteredValue();
isFiltered = filteredGwsReportPartTwoList.size() != gwsReportPartTwoList.size();
countTotalsAndGenerateGwsReportPartOne(isFiltered);
}
但在Primefaces中显示,当Primefaces 3.5返回准备好的过滤列表时,getFilteredValue()返回null。
有什么问题?以及如何检查数据表是否在服务器端显示已过滤的数据?
答案 0 :(得分:2)
我发生了从3.5版到4.0版的事情。 我使用remotecomand解决了问题,调用了actionlistener方法。
<p:dataTable filterDelay="1000" emptyMessage="No se encontraron elementos" widgetVar="tb1"
id="tablaFact" var="item" selection="#{listadoFacturasMB.selectedFactura}" selectionMode="single" paginator="true"
rows="20" rowKey="#{item.idFactura}" value="#{listadoFacturasMB.facturaUtilList}" filteredValue="#{listadoFacturasMB.filterFacturaUtilList}">
<p:ajax event="filter" oncomplete="handleLoadStart();" update=":frm1:tablaFact :frm1:panelTotal"/>
<p:column style="width:10%" headerText="Importe Total" id="cff3">
<h:outputText value="#{item.importeTotal}"/>
</p:column>
<p:column style="width:10%" headerText="Importe CUC" id="cjj3">
<h:outputText value="#{item.importeCuc}"/>
</p:column>
</p:dataTable>
<p:remoteCommand id="rcom" name="loadRemoteContent" process="@this" update="panelTotal, tablaFact"
actionListener="#{listadoFacturasMB.filterListener2}"/>
Backingbean
public void filterListener2() {
try {
if (filterFacturaUtilList != null) {
//your code
}
}
} catch (Exception e) {
JsfUtil.addErrorMessage(e, "Error: filterListener() " + e.getMessage());
}
}
答案 1 :(得分:1)
在PF 5.0中,您需要明确定义filteredValue
:
<p:dataTable id="gwsReportAllPartListDataTable"
value="#{viewAllAnalyticsBean.gwsReportPartTwoList}"
var="report"
paginator="true"
rows="100"
paginatorTemplate="{PageLinks} {CurrentPageReport}"
currentPageReportTemplate="{currentPage} #{dictionary['out_of']} {totalPages}"
emptyMessage="#{dictionary['nothing_is_here']}"
scrollable="true"
scrollWidth="1221"
scrollHeight="500"
filteredValue="#{someBeanOrScope.someList}">