Board index JavaServer Faces General LazyDataModel.load method is not called

LazyDataModel.load method is not called

Components, Ajax Framework, Utilities and More.


Posts: 10
Hi,

In my case datatable component is used together with search form. Below you can find simplified version of the markup:

<h:form>
    <h:inputText value="#{controller.query.firstName}" />
    <h:inputText value="#{controller.query.lastName}" />

    <p:commandButton value="Search" actionListener="#{controller.search}" update="@form" />

    <p:dataTable value="#{controller.employees}" paginator="true" lazy="true">
    ... columns
    </p:dataTable>
</h:form>


LazyDataModel in the controller is implemented as anonymous class, class which is aware of #{controller.query} parameters:

public LazyDataModel<Employee> getEmployees() {
    return employees;
}

@PostConstruct
public void init() {
employees = new LazyDataModel<Employee>() {
    public List<Employee> load(int first, int pageSize, String sortField, boolean sortOrder, Map<String, String> filters) {
   return employeeDao.findByQuery(query, first, pageSize); // query -> #{controller.query}
    }

    public int getRowCount() {
   return employeeDao.countByQuery(query).intValue();
    }
};
}


After search Ajax call only getRowCount is called. If the search query limits the result, the paginator is updated properly.
But load method is not called at all, and the datatable content is not updated.

I suppose that both methods should be called in consistent way.

Marcin
JSF RI 2.0.3
PF 2.2.M1
Glassfish 3.0.1


Posts: 15033
Location: Cybertron

Does load method called when you do page or sort?
PrimeFaces Lead

:shock: The forum can't be used in Chinese. :shock:
Solution See:[url]http://code.google.com/p/primefaces/issues/detail?id=1356[/url]


Return to General