Display tag Issues with pagination and sorting

北战南征 提交于 2019-12-11 12:45:29

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/8343993/display-tag-issues-with-pagination-and-sorting

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!