3

I got dataTable defined as:

<p:dataTable var="account" value="#{customerBean.accounts}"
            id="accounts" lazy="true">
            <p:column>
                <f:facet name="header">
                    <h:outputText value="#{msg['editCustomerForm.accountNumbers.header']}" />
                </f:facet>
                <h:outputText value="#{account.accountNumber}" />
            </p:column>
</p:dataTable>

And accounts are loaded in this method (called in @PostConstruct method)

 private void initAccounts() {
        accounts = new CustomLazyDataModel<Account>() {
            @Override
            public List<Account> load(int first, int pageSize, String sortField, SortOrder sortOrder, Map<String, String> filters) {
                return accountService.getAccountsForCustomer(customerModel.getCustomer(), first, pageSize);
            }
        };
        accounts.setPageSize(10);
    }

CustomLazyDataModel is there only because of this bug: http://code.google.com/p/primefaces/issues/detail?id=1544 (see comment #23)

But when page is rendered, component says "No records found."

SQL in hibernate log executed on the server returns 1 row and when i use dataList insted of dataTable result is corect (1 row is rendered).

<p:dataList value="#{customerBean.accounts}" var="account"
            id="accounts-old" rows="10"
            type="none" lazy="true">
            <f:facet name="header">
                <h:outputText value="#{msg['editCustomerForm.accountNumbers.header']}" />

        </f:facet>

        <h:outputText value="#{account.accountNumber}" />

    </p:dataList>

When using <h:dataTable> records are there also. So what is the problem with <p:dataTable>?

DominikM
  • 1,042
  • 3
  • 16
  • 32
  • What is `CustomLazyDataModel`? Is that some your implementation? – partlov Feb 20 '13 at 10:34
  • According to PrimeFaces code, it prints "No record found" when your method `getRowCount()` returns 0. Are you sore that you set `rowCount`? – partlov Feb 20 '13 at 10:37
  • Yes, it is my implementation and only thing it does is overriding setRowIndex as shown in this comment http://code.google.com/p/primefaces/issues/detail?id=1544#c23 – DominikM Feb 20 '13 at 10:39
  • Good point. When i call accounts.setRowCount(count); message "No record found" disappears, but still no record is rendered. – DominikM Feb 20 '13 at 10:42

1 Answers1

2

Only thing that was missing on the component was rows parameter.

<p:dataTable var="account" value="#{customerBean.accounts}" id="accounts" lazy="true" rows="10"  paginatorAlwaysVisible="false" >

Now records are rendered.

DominikM
  • 1,042
  • 3
  • 16
  • 32