Question

I am using display tag to render tables in my application. When I click either pagination or sorting, it's querying the database again and then sorting/paging. In my opinion, when we are only sorting/paging, we need not query database.

I see following options to tackle this:

  1. I can keep the list (queried from the db) in the session and check it this request is for sorting or pagination then return the list from the session

  2. Or I can maintain a server side cache which will work the same as above

Please correct me if I am missing something I think this functionality should already have been in the display tag library?

Was it helpful?

Solution

I have wondered about this in the past, and from what I've seen, you're on the right track with having to store the data somewhere like the session if you want to use the library-provided pagination/sorting. It doesn't seem to provide a convenient framework to do the actions client-side, or a dummy servlet to that exists just to post/return the same data.

Your alternative is to use external pagination/sorting with a partial list. This requires you to go to the database, but you can return a smaller amount of data than the entire result set.

Here are a couple related posts which seem to imply the same conclusions:

DisplayTag pagination vs Hibernate Pagination

Display tag pagination problem

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top