我正在使用primefaces 5.2和jsf,在我的一个页面中有带有实时滚动的数据表。加载页面后,我显示了23条中的5条记录。最初在向下滚动之前,如果我选择第一条记录或第五条记录,则正确显示相应的选定记录。但是在使用liveScroll来获得第23条记录之后,如果我选择任何一条记录不起作用。(前5个工作) 我再一次从dataTable中选择前5条记录,显示第15条,第16条至第20条记录。
XHTML:
<p:dataTable styleClass="DTAlterColor blueborder mytable" var="data"
rowkey="#{data.planName}" style="margin-top:60px"
value="#{draftplanbean.lazyPlanList}" scrollRows="5" lazy="true"
scrollable="true" liveScroll="true" scrollHeight="150"
id="reqListdtdrft" widgetVar="viewdt0" sortOrder="descending">
<p:columnGroup type="header">
<p:row>
<p:column headerText="Plan Name" rowspan="2"
style="width:100px;height:25px" styleClass="mainheadertxt">
</p:column>
<p:column headerText="Version" rowspan="2"
style="width:40px;height:25px" styleClass="mainheadertxt">
</p:column>
<p:column headerText="Created By" rowspan="2"
style="width:100px;height:25px" styleClass="mainheadertxt">
</p:column>
<p:column headerText="Created On" rowspan="2"
style="width:180px;height:25px" styleClass="mainheadertxt">
</p:column>
<p:column headerText="Last Updated By"
style="width:100px;height:25px" styleClass="mainheadertxt"
rowspan="2">
</p:column>
<p:column headerText="Last Updated On"
style="width:180px;height:25px" styleClass="mainheadertxt"
rowspan="2">
</p:column>
<p:column headerText="Plan Status" style="width:100px;height:25px"
styleClass="mainheadertxt" rowspan="2">
</p:column>
</p:row>
</p:columnGroup>
<p:column style="height:25px">
<p:commandLink
actionListener="#{draftplanbean.savePlanId(data.planId,data.version)}"
update="firstform:lefttabview:diagramfrm,firstform:lefttabview:headingdrafts, firstform:lefttabview:draftlink"
style="text-decoration: none;outline:0">
<f:actionListener
binding="#{draftplanbean.saveFlag(data.approvedFlag)}" />
<h:outputText value="#{data.planName}" styleClass="lighttxt" />
</p:commandLink>
</p:column>
<p:column style="height:25px">
<h:outputText value="#{data.version}" styleClass="lighttxt" />
</p:column>
<p:column style="height:25px">
<h:outputText value="#{data.plan_createdby}" styleClass="lighttxt" />
</p:column>
<p:column style="height:25px">
<h:outputText value="#{data.plan_createdon}" styleClass="lighttxt" />
</p:column>
<p:column style="height:25px">
<h:outputText value="#{data.plan_updatedby}" styleClass="lighttxt" />
</p:column>
<p:column style="height:25px">
<h:outputText value="#{data.plan_updatedon}" styleClass="lighttxt" />
</p:column>
<p:column style="height:25px">
<h:outputText rendered="#{data.approvedFlag==0}" value="Draft"
styleClass="lighttxt" />
<h:outputText rendered="#{data.approvedFlag==3}"
value="Pending For Approval" styleClass="lighttxt" />
<h:outputText id="reworktxt" rendered="#{data.approvedFlag==4}"
value="Rework" styleClass="lighttxt" />
<p:tooltip id="toltip1" for="reworktxt" value="#{data.reworkcomment}"
trackMouse="true" rendered="#{data.approvedFlag==4}" />
</p:column>
</p:dataTable>
<div style="margin-top: 5px">
<h:outputText id="headingdrafts" value="Plan: #{fcbean.pname}"
styleClass="subtxt" />
Managed Bean:
public DraftPlanBean(){
lazyPlanList = new DraftPlanView(getPlans(), draft);
}
模态:
protected int statusflag;
public DraftPlanView(List<PlanVO> datasource, int statusflag) {
this.datasource = datasource;
this.statusflag = statusflag;
}
public List<PlanVO> load(int first, int pageSize, String sortField, SortOrder sortOrder, Map<String, Object> filters) {
Map<String, String> filtersnew = ConUtil.convertFilters(filters);
setFilterGlobal(filtersnew);
String globalSortField = (String) SessionMgr.getSessionData("globalsortkey");
return load1(first, pageSize, sortField, sortOrder, filtersnew, globalSortField);
}
public void setFilterGlobal(Map<String, String> filters) {
if (SessionMgr.getSessionData("globalfilterkey") != null) {
if (!SessionMgr.getSessionData("globalfilterkey").equals("")) {
String filterKey = (String) SessionMgr.getSessionData("globalfilterkey");
String filterVal = (String) SessionMgr.getSessionData("globalfiltervalue");
filters.put(filterKey, filterVal);
}
if (SessionMgr.getSessionData("globalfilterkey").equals("clearfilter")) {
filters.clear();
}
}
}
public List<PlanVO> load1(int first, int pageSize, String sortField, SortOrder sortOrder,
Map<String, String> filters, String globalSortField) {
PlanProcess pprocess = PlanProcess.getPlanProcess();
List<PlanVO> lst = null;
try {
lst = pprocess.getDraftedPlansList(first, pageSize, sortField, sortOrder, filters, SessionMgr.getProject(),
statusflag, globalSortField);
System.out.println("The list size is"+ lst.size());
datasource.addAll(lst);
if(lst.size()>0){
this.setRowCount(pprocess.getPlansCount(filters, SessionMgr.getProject(), false, statusflag));
}
} catch (Exception ex) {
ex.printStackTrace(); // temporary fix for exception handling
}
return lst;
}
}
我想从dataTable显示所选记录,我该怎么做?