2
votes

In many project which I take care of it there is nothing like lazy paging in datatables.

Does JSF have some kind of magic or am I right that its really big performance problem. If you watch some tutorials almost no one take care of lazy paging

Lets say you got List on backing bean and you have 2000 rows in DB. If I ll use ORM (JPA) when I want to display DataTable with this list from backing bean. JPA has to map 2000 objects this operation will take some times also allocate a lot of memory.(now imagine 50000 or 1 million objects). I dont even mentioned that lazzy fetching is not setup.

Is this something what should I take care of it? Also are this objects reusable through application. If two visitors want see same datatable. I hope at least this is true.

What is best solution create event on datatable and in service have method which return data in specified range?

1
What JSF libraries are you using? Mojarra, MyFaces, PrimeFaces, ICEFaces, RichFaces, etc? - Buhake Sindi
reference Mojarra implementation. Is this take a point? - Milkmaid
@BuhakeSindi : Mojarra and MyFaces are JSF implementations (implemented by Oracle and Apache respectively). Technically, they are not said to be libraries. - Tiny

1 Answers

1
votes

Primefaces has a component that directly supports your requirement

http://www.primefaces.org/showcase/ui/data/datatable/lazy.xhtml

And this blog post gives you a complete example, using the data table lazy loading, with pagination and backed by JPA criteria

http://www.javacodegeeks.com/2014/01/primefaces-datatable-lazy-loading-with-pagination-filtering-and-sorting-using-jpa-criteria-viewscoped.html