I am using Hibernate 4, Spring 3 and JSF 2.0 with Weblogic 10.3.6 as server.
I have two datatables in one page, in order to populate datatable I am using lazy loading.
The problem I am facing is when both the datatables are displayed, then pagination doesn't work. It does goes to page 2 and 3 and so forth, but records in datatable remains the same for both datatable. If I remove either one of them then pagination works perfectly.
I have noticed that even filter is not working when I have multiple datatables. Both datatables are in a single form, they both do have two different ManagedBeans and both are of view scope. I have tried with request scope, but didn't solve my problem.
How can I resolve this issue?
JSF Code
<h:form id="form">
<!-- Master form -->
<p:dataTable id="dataTable" var="req" lazy="true" value="#{emp.lazyModel}"
paginator="true" rows="10"
selection="#{emp.selectedRequest}"
selectionMode="single">
<p:ajax event="rowSelect" listener="#{emp.onRowSelect}" />
<p:column id="empNo" filterBy="#{req.empNo}"
headerText="Request No" footerText="contains"
filterMatchMode="endsWith">
<h:outputText value="#{req.empNo}" />
</p:column>
other columns
</p:dataTable>
<!-- Detail form -->
<p:dataTable id="dataTableDet" var="reqAct" lazy="true" value="#{dept.lazyModel}"
paginator="true" rows="1"
rowsPerPageTemplate="5,10">
<f:facet name="header">
Emp Details
</f:facet>
<p:column>
<f:facet name="header">
<h:outputText value="SLNo" />
</f:facet>
<h:outputText value="#{reqAct.slNo}" />
</p:column>
<p:column id="empNo" filterBy="#{reqAct.empNo}"
headerText="Request No" footerText="contains"
filterMatchMode="endsWith">
<h:outputText value="#{reqAct.empNo}" />
</p:column>
other columns
</p:dataTable>
</h:form>
Managedbean First Datatable
@Named("emp")
@Scope("view")
@PostConstruct
public LazyDataModel<Employee> getLazyModel() {
if (lazyModel == null) {
lazyModel = new LazyRequestDataModel(empList, empService) {
};
}
return lazyModel;
}
Managedbean Second Datatable
@Named("dept")
@Scope("view")
@PostConstruct
public LazyDataModel<Department> getLazyModel() {
if (lazyModel == null) {
lazyModel = new LazyRequestActivitiesDataModel(deptList,
deptService) {
};
}
return lazyModel;
}