我在dataTable中遇到延迟加载的问题,但无法知道问题出在哪里, 这是我的xhtml页面代码:
<f:view xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<h:head>
<title>Application</title>
</h:head>
<h:body>
<h:form>
<h:panelGrid columns="2">
<h:outputLabel value="Element per page"/>
<p:selectOneMenu value="#{applicationManagementListBean.pageSize}">
<f:selectItem itemLabel="5" itemValue="5"/>
<f:selectItem itemLabel="10" itemValue="10"/>
<f:selectItem itemLabel="30" itemValue="30"/>
<f:selectItem itemLabel="50" itemValue="50"/>
<p:ajax event="change" update="applicationDataList"/>
</p:selectOneMenu>
</h:panelGrid>
<p:commandButton value="New application"
action="inscription.xhtml?faces-redirect=true" ajax="false" />
<p:dataTable id="applicationDataList" value="#{applicationManagementListBean.applications}"
var="app" paginator="true"
rows="#{applicationManagementListBean.pageSize}" lazy="true"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}">
<p:column headerText="Code">
<h:outputText value="#{app.code}" />
</p:column>
<p:column headerText="Name">
<h:outputText value="#{app.name}" />
</p:column>
<p:column headerText="Abreviate name">
<h:outputText value="#{app.abrevName}" />
</p:column>
<p:column headerText="Status">
<h:outputText value="#{app.status.description}" />
</p:column>
</p:dataTable>
</h:form>
</h:body>
</f:view>
和bean代码:
@ManagedBean
@ViewScoped
public class ApplicationManagementListBean implements Serializable {
private static final long serialVersionUID = 1L;
@ManagedProperty(value = "#{applicationManagementService}")
public ApplicationManagementRemote applicationManagementService;
private Integer pageSize = 3;
private DataProxyLazyDataModel data;
public void setApplicationManagementService(
ApplicationManagementRemote applicationManagementService) {
this.applicationManagementService = applicationManagementService;
}
public LazyDataModel<Object> getApplications() {
data = new DataProxyLazyDataModel(applicationManagementService);
data.setPageSize(pageSize);
return data;
}
public Integer getPageSize() {
return pageSize;
}
public void setPageSize(Integer pageSize) {
this.pageSize = pageSize;
}
public DataProxyLazyDataModel getData() {
return data;
}
public void setData(DataProxyLazyDataModel data) {
this.data = data;
}
}
当我点击下一页按钮时没有任何事情发生
请帮忙 非常感谢 最好的问候,Rachid
primegaces 3.4.2,liferay portal 6.1,eclipse
答案 0 :(得分:0)
尝试将setRowCount()
添加到您的lazyDataModel
。
例如:
lazyDataModel.setRowCount(rows);
其中rows表示数据库中要显示在DataTable
中的总记录数。
在您的情况下代码是:
data.setRowCount(rows);