简体   繁体   English

数据表JSF中的延迟加载

[英]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. JSF是否具有某种魔力,或者说它确实是一个很大的性能问题,对吗? 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. 假设您在支持bean上获得了List,并且在DB中有2000行。 If I ll use ORM (JPA) when I want to display DataTable with this list from backing bean. 如果我想使用支持bean中的此列表显示DataTable时使用ORM(JPA)。 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). JPA必须映射2000个对象,此操作将花费一些时间,并且还会分配大量内存。(现在设想50000或100万个对象)。 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 Primefaces具有直接支持您的要求的组件

http://www.primefaces.org/showcase/ui/data/datatable/lazy.xhtml 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 这篇博客文章为您提供了一个完整的示例,其中使用了数据表的延迟加载,分页和JPA条件支持

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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