Reputation: 309
I've been using Struts2 as my MVC framework as part of building a J2EE-based web application.
Part of the application is to display reports (HTML tables) that are mainly thousands of rows and tens of columns in size. I have implemented pagination to make the report readable etc...
The way the reporting system works today is as follows: The entire data is prepared in an OOP approach and placed on the ValueStack. A corresponding JSP would read the data of the valueStack and use JSTL to draw the HTML code.
I'm in the process of revamping the code and i would like to revisit this logic to conform with the best practices in the industry. The main question here, what are the best practices out there?
Rendering and drawing the report is taking time. Especially on IE-based browsers where the page becomes unresponsive until data is shown (IE8 support is a must im afraid). So what is the best option?
Is it using javascript frameworks such as jQuery and move the drawing part to be client-side? Do I know store the entire HTML code on the value stack somehow and display it in 1 shot? What's the optimal way in your opinion?
Upvotes: 0
Views: 144
Reputation: 50203
When and how to use pagination is primarily use-case based, and should be evaluated for each case, basing on the number of overall records, the number of records per page, the size of a single record, the main devices used in the ecosystem (prevalently desktop, prevalently mobile, mixed, etc...), network, server and database capabilities, and so on.
But IF you decide to go with pagination (if you have a lot of record, it is the only choice), then the only Best Practice is to load only the data needed for that request.
If you want to see results from 90 to 100 in a resultset of 10.000, it would be awful to load all the 10.000 records in the page; it would be also wrong to load all the 10.000 records serverside, then transmitting only the 10 requested to the client; the filtering must be applied at the lowest possible level, generally the database.
Since you have tagged this Struts2, jQuery and Grid, I strongly suggest you to take a look at the Struts2-jQuery-Grid-Plugin, and its Showcase.
It is new and actively maintained, it only needs a small effort on the initial learning curve.
It is the Struts2 wrapper of the native jQueryGrid (you can use the original one, if you want to handle the Javascript on your own).
There are over 200 questions here on SO on jQGrid pagination, good read.
Upvotes: 1