What I have is a calendar and a lazy DataTable. When a date is selected, the DataTable should call the method load of its LazyDataModel. But this is not happening. Here's the code:
In view:
Code: Select all
<p:calendar mode="inline" value="#{myMB.date }" onSelectUpdate="table" selectListener="#{myMB.handle}" rowsPerPageTemplate="5,10,15"/>
<p:dataTable id="table" var="car" value="#{myMB.lazyModel}" paginator="true" rows="10" lazy="true">
<p:column>
<h:outputText value="#{car} />
</p:column>
</p:dataTable>
Code: Select all
public void handle(DateSelectEvent event) {
setDate(event.getDate()); //no need, but let it here for now
}
public LazyDataModel<Car> getLazyModel() {
loadModel();
return lazyModel;
}
private void loadModel() {
if (lazyModel == null) {
lazyModel = new LazyDataModel<Car>() {
@Override
public List<Car> load(int first, int pageSize,
String sortField, boolean sortOrder,
Map<String, String> filters) {
return mYMethodThatDOESReturnSomething(pageSize, first);
}
};
lazyModel.setRowCount(10);//just for text
}
}