简体   繁体   中英

Lazy loading in datatable JSF

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM