Problem with LazyDataModel of DataTable

Components, Ajax Framework, Utilities and More.
Post Reply
duocls
Posts: 1
Joined: 17 Oct 2011, 12:35

17 Oct 2011, 12:51

Hi all,

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;
    }
The above code seems to be similar with the example in PrimeFaces showcase site. The Cars object contains data which are loaded from my database. In populateLazyCar(List<Car> lazyCar, int size) function, I split the Cars list into many parts which are corresponding to each page.

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 read many threads in this forum to find my own solution but I still get stuck on it.

I appreciate if you can help me solve this issue.

sezayir
Posts: 4
Joined: 13 Oct 2011, 12:28

17 Oct 2011, 15:17

I could not used LazyDataModel of DataTable and I wrote my custome code.

viewtopic.php?f=3&t=15505

Post Reply
  • Information
  • Who is online

    Users browsing this forum: Bing [Bot] and 10 guests