I'm using PrimeFaces version 2.2, Apache Tomcat server 7.
I have a class as below, it's a portion of my whole source code. I expect to apply pagination with lazy loading in a data table.
Code: Select all
private int offset = 0;
public CarSearchBean() {
lazyModel = new LazyDataModel<Car>() {
@Override
public List<Car> load(int first, int pageSize, String sortField, boolean sortOrder,
Map<String, String> filters) {
lazyCar = new ArrayList<Car>();
populateLazyCar(lazyCar, pageSize);
return lazyCar;
}
};
lazyModel.setRowCount(100000000);
}
public void populateLazyCar(List<Car> lazyCar, int size) {
lazyCar = Cars.subList(this.offset, this.offset + size);
this.offset = this.offset + size;
}
However, when executing it, an exception occurs :
Code: Select all
SEVERE: java.lang.ClassCastException: javax.faces.model.ListDataModel cannot be cast to org.primefaces.model.LazyDataModel
I appreciate if you can help me solve this issue.