如何在延迟加载数据表中获取页码



我有一个延迟加载的数据表,我想将XHTML中的页码或行数传递给ManagedBean。我该怎么做?这是我正在使用的数据表:

<p:dataTable var="studyPlanList" value="#{editBean.lazyModel}"
        paginator="true" rows="5"
        paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}"
        rowsPerPageTemplate="5,10,15" selectionMode="single"
        selection="#{editBean.selectedStudyPlan}" id="studyPlanTable">
        <p:ajax event="rowSelect" listener="#{editBean.onRowSelect}"
            update=":studyPlanEditForm :relatedFileEditForm" />
        <p:column headerText="StudyPlan" sortBy="#{studyPlanList.name}"
            filterBy="#{studyPlanList.name}" width="100">
            <h:outputText value="#{studyPlanList.name}" />
        </p:column>
        <p:column headerText="StudyPlan Status" width="100">
            <h:graphicImage
                value="#{editBean.statusKeyMap.get(studyPlanList.status)}"
                style="float:center;height: 18px;width: 20px"
                title="#{editBean.statusTitleMap.get(studyPlanList.status)}" />
        </p:column>
        <p:column headerText="Messages" width="100">
            <ui:fragment rendered="#{studyPlanList.status eq 300}">
                <h:outputText style="font: italic;"
                    value="Please click Finish Editing to Finish SpokenTutorial" />
            </ui:fragment>
        </p:column>
    </p:dataTable>

如果您使用LazyLoading,那么在您的bean中您有一个LazyDataModel的实现,并且您正在重写方法load(int first, int pageSize, String sortField, SortOrder sortOrder, Map<String,String> filters)。您应该从该方法内部从数据库加载集合,这里有页面大小和要检索的第一条记录(页码为first / pageSize

最新更新