Sep 9th, 2008, 08:38 AM
A spring based pagination solution for J2EE web application
HDPagination is a framework to provide an efficient and consistent solution for pagination search over large result set in J2EE Web application.
Today in java world you can find many frameworks or components or libraries to deal with the pagination issue in J2EE applications. By leveraging these kinds of common components developers can save a lot of effort to implement the pagination functionalities in their applications, however almost all of these solutions adopt the same strategy, that is, fetching all records that satisfies the input search criteria from database and storing them in memory (typically store them as an attribute of HttpServletSession in J2EE Web application), then the built-in UI components (e.g. Tag or UIComment in JSF) choose one page of data to display. When users navigate through different pages, the UI components only navigates though the records saved in session to pick out part of data for that page, without hitting database again.
This kind of solution works very well if the search result is small, however when data becomes big it can cause a big performance problem because saving huge amount of data in session will cost a lot of memory.
Our solution is to load the data of one particular page only from database. And when user navigates to anther page (e.g. by clicking "Previous" or "Next" page links), the framework can "remember" the previous search criteria and use it together with the passed page number to query against database to load that particular page of data. This kind of strategy can avoid the performance problem mentioned above.
To facilitate the development of the pagination based search functionality, the framework provides:
1.Some useful tags to display page links and navigation links where user can navigate through different pages.
2.Some other tags to display pagination related information (e.g. “Total Records”, “Current Page Number”, “Number of total pages”) which are commonly seen in a typical pagination featured web page.
The framework supports pagination based query against different types of persistence technologies including JDBC (that is to run SQL against JDBC API) and ORM (that is to run Query Statement against OR-Mapping engine).
From JDBC perspective, Oracle, DB2, MySQL and HSQLDB databases are supported in current version.
From ORM perspective, JPA, Hibernate2 and Hibernate3 are supported in current version.
If you use JDBC persistence technology, you don’t have to write the tedious paginated SQL (each database has different SQL syntax to support pagination feature) and the SQL of counting total records for current search. You only provide the original SQL and framework can do the automatic SQL translation based on the chosen database provider. Similarly if you use JPA or Hibernate, you also don’t have to create an additional Query statement to count the total records yourself and framework can do it for you automatically.
This framework is MVC independent. It can be run in any J2EE Web applications and is not coupling with any particular MVC framework such as Struts or Spring-MVC.
It only replies on spring IoC (Inversion of Control) container to configure and assemble its components.
You can download the framework and related document from here:
Sep 10th, 2008, 01:54 PM
that's just great hope to see an example soon