gpt4 book ai didi

jsf - primefaces 中延迟加载的分页无法正常工作

转载 作者:行者123 更新时间:2023-12-03 04:42:32 27 4
gpt4 key购买 nike

我在数据表中遇到延迟加载问题,但不知道问题出在哪里,这是我的 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;
}

}

当我点击下一页按钮时没有任何反应

请帮忙多谢最好的问候,拉希德

primegaces 3.4.2,liferay门户6.1,eclipse

最佳答案

尝试将 setRowCount() 添加到您的 lazyDataModel 中。

例如:

lazyDataModel.setRowCount(rows);

其中行代表数据库中要在DataTable 中显示的总记录。在您的情况下,代码是:

data.setRowCount(rows);

关于jsf - primefaces 中延迟加载的分页无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15724232/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com