数据表JSF中的延迟加载 [英] Lazy loading in datatable JSF
问题描述
在许多我关心的项目中,没有什么比数据表中的惰性分页更重要了.
In many project which I take care of it there is nothing like lazy paging in datatables.
JSF是否具有某种魔力,或者说它确实是一个很大的性能问题,对吗?如果您看了一些教程,几乎没有人会照顾到懒惰的分页
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
让我们说您在支持bean上获得了List,并且在DB中有2000行. 如果我想使用后备bean的此列表显示DataTable时使用ORM(JPA). JPA必须映射2000个对象,此操作将花费一些时间,并且还会分配大量内存.(现在设想50000或100万个对象). 我什至都没有提到过没有设置lazzy的获取功能.
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具有直接支持您需求的组件
Primefaces has a component that directly supports your requirement
http://www.primefaces.org/showcase/ui/data/datatable/lazy.xhtml
这篇博客文章为您提供了一个完整的示例,它使用了数据表的延迟加载,分页和JPA条件支持
And this blog post gives you a complete example, using the data table lazy loading, with pagination and backed by JPA criteria
这篇关于数据表JSF中的延迟加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!