我很长一段时间都遇到过这个问题,但没有找到任何帮助或解决方法来避免这种情况。
<p:dataTable>
已设置为livescroll并已启用排序。
当多次滚动和排序时,将显示重复的记录。
例如:总记录为150,显示200条记录,50条重复。
有人知道,如果这是PrimeFace的已知问题或<p:dataTable>
使用错误吗?
<p:dataTable var="enty" value="#{reportListBean.entities}" id="list"
scrollRows="50" scrollable="true" liveScroll="true"
scrollHeight="600"
filteredValue="#{reportListBean.filteredEntities}"
filterEvent="enter" widgetVar="reportList">
<h:outputScript target="body" library="js" name="reportList.js" />
<p:ajax event="rowToggle" onstart="synchronizeRowToggler();"
listener="#{reportListBean.onRowToggle}" />
<p:ajax event="filter" listener="#{reportListBean.filterReportList}"
onstart="PF('blockUIWidget').block()"
oncomplete="PF('blockUIWidget').unblock()" />
<p:columnGroup type="header">
<p:row>
<p:column headerText="xx" style="width:4%" />
<p:column headerText="xxx" style="width:11%" sortBy="userName" />
<p:column headerText="xxx" style="width:15%" sortBy="name" />
<p:column headerText="xxx" style="width:10%"
sortBy="description" />
<p:column headerText="xx" style="width:5%" />
<p:column headerText="xxx" style="width:8%" />
<p:column headerText="xx" style="width:6%" />
<p:column headerText="xx" style="width:6%" />
<p:column headerText="xx" style="width:30%" />
<p:column headerText="xx" style="width:7%" />
</p:row>
<p:row>
<p:column />
<p:column filterMatchMode="contains" filterBy="userName"
filterStyle="width:80px;" />
<p:column>
<f:facet name="header">
<p:inputText value="#{reportListBean.listFilter.rptid}"
onkeyup="filterReportList()" size="25"></p:inputText>
</f:facet>
</p:column>
<p:column>
<f:facet name="header">
<p:inputText value="#{reportListBean.listFilter.nameCh}"
onkeyup="filterReportList()" style="width:75px"></p:inputText>
</f:facet>
</p:column>
<p:column />
<p:column filterMatchMode="contains" filterBy="timesBrowsed"
filterStyle="width:65px;" />
<p:column />
<p:column />
<p:column>
<f:facet name="header">
<p:outputPanel id="dateFilter">
<p:selectBooleanButton value="#{reportListBean.fromIsDate}"
onLabel="曆" offLabel="距">
<p:ajax update="dateFilter"
listener="#{reportListBean.fromIsDateChanged}" />
</p:selectBooleanButton>
<p:calendar value="#{reportListBean.listFilter.fromDate}"
pattern="yyyy-MM-dd HH:mm:ss" navigator="true"
onkeyup="filterReportList()" label="建立於日期時間"
rendered="#{reportListBean.listFilter.fromIsDate}" />
<p:inputText value="#{reportListBean.fromIntervalStr}"
onkeyup="filterReportList()" label="建立於起始區間"
rendered="#{!reportListBean.listFilter.fromIsDate}">
<f:validateRegex pattern="^([0-9]{0,6})$" />
</p:inputText>
<p:selectBooleanButton value="#{reportListBean.toIsDate}"
onLabel="曆" offLabel="距">
<p:ajax update="dateFilter"
listener="#{reportListBean.toIsDateChanged}" />
</p:selectBooleanButton>
<p:calendar value="#{reportListBean.listFilter.toDate}"
pattern="yyyy-MM-dd HH:mm:ss" navigator="true"
onkeyup="filterReportList()" label="建立至日期時間"
rendered="#{reportListBean.listFilter.toIsDate}" />
<p:inputText value="#{reportListBean.toIntervalStr}"
onkeyup="filterReportList()" label="建立至終止區間"
rendered="#{!reportListBean.listFilter.toIsDate}">
<f:validateRegex pattern="^([0-9]{0,6})$" />
</p:inputText>
</p:outputPanel>
</f:facet>
</p:column>
<p:column />
</p:row>
</p:columnGroup>
<p:column>
<p:rowToggler />
</p:column>
<p:column>
<h:outputText value="#{enty.userName}"
styleClass="ui-outputText-rptListCell" />
</p:column>
<p:column>
<h:outputText value="#{enty.name}" rendered="#{!enty.canBrowse}"
styleClass="ui-outputText-rptListCell" />
<p:commandLink id="cL_Browse"
action="#{reportListBean.browseReport(enty)}"
rendered="#{enty.canBrowse}" onstart="PF('blockUIWidget').block()">
<h:outputText value="#{enty.name}"
styleClass="ui-outputText-rptListCell" />
</p:commandLink>
</p:column>
<p:column>
<h:outputText value="#{enty.description}"
styleClass="ui-outputText-rptListCell" />
</p:column>
<p:column>
<h:outputText value="#{enty.pages}"
styleClass="ui-outputText-rptListCell" />
</p:column>
<p:column>
<h:outputText value="#{enty.timesBrowsed}"
styleClass="ui-outputText-rptListCell" />
</p:column>
<p:column>
<h:outputText value="#{enty.timesPrinted}"
styleClass="ui-outputText-rptListCell" />
</p:column>
<p:column>
<h:outputText value="#{enty.timesDownloaded}"
styleClass="ui-outputText-rptListCell" />
</p:column>
<p:column>
<h:outputText value="#{enty.createDateStr}"
styleClass="ui-outputText-rptListCell" />
</p:column>
<p:column>
<h:outputText value="#{enty.jobID}"
styleClass="ui-outputText-rptListCell" />
</p:column>
<p:rowExpansion>
<p:panelGrid style="width:100%">
<f:facet name="header">
<p:row>
<p:column style="text-align:left;border-style: none;width:60%">
<h:outputText value="op" />
  
<p:commandButton id="browse"
action="#{reportListBean.browseReport(enty)}" value="開啟"
rendered="#{enty.canBrowse}"
onstart="PF('blockUIWidget').block()" />
<p:commandButton id="print" value="pr"
action="#{reportListBean.printReport(enty)}"
rendered="#{enty.canPrint}" update="list"
onstart="PF('blockUIWidget').block()"
oncomplete="PF('blockUIWidget').unblock()" />
<p:commandButton id="downloadCopy" value="dw"
actionListener="#{reportListBean.downloadReportCopy(enty)}"
rendered="#{enty.canDownloadCopy}" ajax="false"
onclick="PrimeFaces.monitorDownload(start, stop)">
<p:fileDownload value="#{enty.downloadFile}" />
</p:commandButton>
<p:commandButton id="download" value="dw"
actionListener="#{reportListBean.downloadReport(enty)}"
rendered="#{enty.canDownload}" ajax="false"
onclick="PrimeFaces.monitorDownload(start, stop)">
<p:fileDownload value="#{enty.downloadFile}" />
</p:commandButton>
</p:column>
<p:column style="border-style: none;">
</p:column>
</p:row>
</f:facet>
<p:row>
<p:column style="border-style: none;">
<p:dataGrid var="aField" value="#{enty.fields}" columns="3"
styleClass="ui-datagrid-expand">
<p:row>
<p:column>
<p:panelGrid style="width:100%"
styleClass="ui-panelgrid-nogrid">
<p:row>
<p:column
style="text-align:right;border-style:none;font-weight:bold;width:30%">
<h:outputText value="#{aField.fieldName}" escape="false" />
</p:column>
<p:column
style="text-align:left;border-style:none;font-style:italic;">
<h:outputText value="#{aField.fieldValue}" escape="false" />
</p:column>
</p:row>
</p:panelGrid>
</p:column>
</p:row>
</p:dataGrid>
</p:column>
<p:column style="border-style: none;">
<center>
<h:outputText value="noaccess" rendered="#{!enty.canComment}" />
</center>
<p:scrollPanel mode="native" style="height:300px"
rendered="#{enty.canComment}">
<center>
<h:outputText value="nocomment"
rendered="#{enty.conversationMap.entrySet().isEmpty()}" />
</center>
<ui:repeat value="#{enty.conversationMap.entrySet().toArray()}"
var="conversationGroup">
<p:panel
header="第#{conversationGroup.key.pageIndex}頁[#{conversationGroup.key.coordX},#{conversationGroup.key.coordY}]"
styleClass="ui-panel-conversation">
<ui:repeat value="#{conversationGroup.value}"
var="conversationEntry">
<p:panelGrid style="width:100%"
styleClass="ui-panelgrid-nogrid">
<p:row>
<p:column style="border-style: none;">
<h:outputText value="#{conversationEntry.userName}"
style="font-weight:bold" />
<h:outputText
value="(#{enty.getShortDateString(conversationEntry.createDate)}):" />
</p:column>
</p:row>
<p:row>
<p:column
style="background-color:#E7E5DC;border-style: none;">
<h:outputText value="#{conversationEntry.text}" />
</p:column>
</p:row>
</p:panelGrid>
</ui:repeat>
</p:panel>
<p:spacer width="100%" height="5" />
</ui:repeat>
</p:scrollPanel>
</p:column>
</p:row>
</p:panelGrid>
</p:rowExpansion>
</p:dataTable>
public List<ReportListItem> getFilteredEntities() {
return filteredEntities;
}
public void setFilteredEntities(List<ReportListItem> filteredEntities) {
this.filteredEntities = filteredEntities;
}