简体   繁体   中英

How to pass data from database to JSF page?

I want to pass data from database to JSF page as a table. I know that I can use ArrayList but I need more efficient way because I have database tables with 2000+ rows and more. I;m not sure but the ArrayList will consume too much memory. Is there more memory efficient way to send the data to the JSF page?

PS maybe using pagination?

You can start with a simple PrimeFaces - DataTable - Pagination Example... its really simple and efficient...

DataTable has built-in support for ajax pagination.

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

DataTable has built-in support to deal with huge datasets. In order to enable lazy loading, a LazyDataModel needs to be implemented to query the datasource when pagination, sorting, filtering or live scrolling happens

And here is a link to all PrimeFaces Datatable ability's

With Richfaces you can use database backed pagination. There is a bunch of example/tutorials if you search for richfaces pagination. Here is one that looks promising:

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

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