0

我需要帮助。如果有人可以提供帮助,我将不胜感激。

我有一个带有分页的数据表,我想在数据表之外(在托管 Bean 中)有来自 paginatorTemplate(RowsPerPageDropdown 和 CurrentPageReport)的分页数据,我怎样才能得到它?

表格形式如下:

<h:form id="form"> 
<p:dataTable id="myDataTable" var="member" 
value="#bean01MyWorkspaces.dqaSqlsExecutiveBeanList}" rows="1" paginator="true"
currentPageReportTemplate="Showing {startRecord}-{endRecord} out of {totalRecords}"
paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}"
rowsPerPageTemplate="2,3,4" > ...

第一个按钮用数据填充表格(并且工作正常):

<p:commandButton value="User Datasources"
action="#{bean01MyWorkspaces.initDqaSqlsExecutiveBeanList()}"
style="width:100%;height:100%; margin-bottom: 5px"
update="myDataTable"/>

使用第二个按钮,我试图获取分页数据(从 RowsPerPageDropdown 和 CurrentPageReport 中选择):

<p:commandButton value="User Datasources 2"
action="#{bean01MyWorkspaces.changeMethod}"
style="width:100%;height:100%; margin-bottom: 5px"
/>
</h:form> 

而 Bean 方法是:

public void changeMethod() {
    final DataTable d = (DataTable) FacesContext.getCurrentInstance().getViewRoot().findComponent("form:myDataTable");
    int first = 1;
    if(d == null){
        System.out.println("SYSTEM is NULL V"  );
    }else{
        System.out.println("getRowCount is NOT NULL " +d.getRowCount() );
        System.out.println("getCurrentPageReportTemplate is NOT NULL " +d.getCurrentPageReportTemplate());
    }
}

如何从 bean 方法访问 RowsPerPageDropdown 列表和 CurrentPageReport 中的实际/当前值?

提前致谢!

4

1 回答 1

0

在这种情况下,而不是 DataTable - Basic 使用 DataTable - Lazy。

Primefaces SHOWCASE 数据表 - 懒惰

于 2017-02-18T05:33:33.307 回答