LazyDataModel.load method is not called

UI Components for JSF
Post Reply
mkuthan
Posts: 10
Joined: 25 Jun 2010, 10:54

10 Sep 2010, 12:26

Hi,

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

Code: Select all

<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:

Code: Select all

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

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

16 Sep 2010, 20:20

Does load method called when you do page or sort?

mylife1000@gmail.com
Posts: 1
Joined: 23 Oct 2010, 12:42

23 Oct 2010, 12:59

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

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 16 guests