简体   繁体   English

如何将数据从数据库传递到JSF页面?

[英]How to pass data from database to JSF page?

I want to pass data from database to JSF page as a table. 我想将数据作为表从数据库传递到JSF页面。 I know that I can use ArrayList but I need more efficient way because I have database tables with 2000+ rows and more. 我知道我可以使用ArrayList但是我需要更有效的方法,因为我的数据库表包含2000多个行。 I;m not sure but the ArrayList will consume too much memory. 我不确定,但是ArrayList将消耗太多内存。 Is there more memory efficient way to send the data to the JSF page? 是否有更有效的内存方式将数据发送到JSF页面?

PS maybe using pagination? PS也许使用分页?

You can start with a simple PrimeFaces - DataTable - Pagination Example... its really simple and efficient... 您可以从一个简单的PrimeFaces-DataTable-分页示例开始...它的确非常简单而高效...

DataTable has built-in support for ajax pagination. DataTable内置了对ajax分页的支持。

Then if you will deal with really huge data you can take a look at a more advanced example. 然后,如果您要处理非常大的数据,则可以看一个更高级的示例。

Take a look at the PrimeFaces DataTable - Lazy Loading example 看一下PrimeFaces DataTable-延迟加载示例

DataTable has built-in support to deal with huge datasets. DataTable具有内置支持,可以处理庞大的数据集。 In order to enable lazy loading, a LazyDataModel needs to be implemented to query the datasource when pagination, sorting, filtering or live scrolling happens 为了启用延迟加载,当实现分页,排序,过滤或实时滚动时,需要实现LazyDataModel来查询数据源

And here is a link to all PrimeFaces Datatable ability's 这是所有PrimeFaces Datatable功能的链接

With Richfaces you can use database backed pagination. 借助Richfaces,您可以使用数据库支持的分页。 There is a bunch of example/tutorials if you search for richfaces pagination. 如果您搜索richfaces分页,则有大量示例/教程。 Here is one that looks promising: 这是一个看起来很有前途的:

http://www.myjeeva.com/2011/04/do-jsfrichfacesseam-lazydynamic-data-loading-pagination/ http://www.myjeeva.com/2011/04/do-jsfrichfacesseam-lazydynamic-data-loading-pagination/

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

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