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>
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();
}
};
}
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