Lazy loading in datatable JSF

社会主义新天地 提交于 2019-12-10 11:19:02

问题


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:


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



来源:https://stackoverflow.com/questions/28559089/lazy-loading-in-datatable-jsf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!