Large JSF data table supported by a database that can handle paging / sorting

If you have a large amount of tabular data that I am trying to display in a JSF file. Are there any implementations or components that can handle paging and database sorting?

Currently, I have to pull all the rows in the table and handle the paging and sort the client side in JSF. Unfortunately, this is not very significant and sometimes leads to the fact that my application server runs out of memory.

Ideally, this implementation version could wrap the JDBC request or the Hibernate request in some way. I'm not stuck in JSF 1.2, I plan to upgrade to version 2.0 in the near future, if that matters.

+4
source share
3 answers

Check richfaces datatable datatable with filtering table and sorting table Or advanced datatable

But yes, I forgot one small note :). If you need to go to the database and handle your filtering / sorting at the db level, you will need to provide your own implementation of DataModel, expanding org.ajax4jsf.model. SerializableDataModel.

Some blogs go this way, see this

+3
source

You will always have memory problems when Java code moves / copies a whole dataset of data (e.g. RDBMS) into Java memory, and then sorts and filters directly in Java memory using Java code. It will be even worse if you even save it in the session area of ​​a web application.

The most effective approach to memory is to allow the database to perform the task for which it is intended. The SQL language prompts you to sort under each ORDER BY WHERE , the WHERE to filter, and certain DB vendor specific LIMIT/OFFSET clauses / subqueries / functions to return only a subset of records based on firstrow and rowcount or lastrow. That way, you only get the dataset in the Java memory that should actually be displayed.

There is no standard JSF component that does just that. This will always require a complete dataset in the Java memory, as filtering and sorting must be done using pure Java code or Javascripts. JSF does not know anything about SQL, you need to provide a custom implementation of javax.faces.model.DataModel for datatable and / or control / management, which is at the data access level. You can get a lot of new ideas / ideas and find a launch example in this article . You can also find examples of the necessary SQL queries in this JSP-addressed answer , which I posted here.

Good luck.

+2
source

Source: https://habr.com/ru/post/1303008/


All Articles