In display tag i used pagination feature ,when i want to see the list of 15 rows but display tag featch all the rows from database. every time when i click on pagination number,it featch all of the rows from db.bcoz of that it slow the performace of application.
I want that in display tag when i want to see the 15 rows then display tag also fetch 15 rows from db not entire db rows. Plz help me if some one knows.
Displaytag sends it’s pagination and sorting data using parameters that start with “d-”. So quick solution can be to check if request contains something starting with "d-",if yes then dont execute your query again.
For some reason using the
PaginatedList
didn't seem to work. I tried with the latest version and it seems there is some bug and it gives the errorattribute size must be specified
even if I hard code the size value. I went through other links/blogs and many people have pointed this out.The option which I finally used is to store the data in the session. When the user clicks next it checks the data in session. If present, it will not hit the services layer. So far it has worked fine.
You have to use external pagination feature. First, specify in html tag that you're using external pagination. And create an object implements org.displaytag.pagination.PaginatedList. Finally, you have to implement the DAO which makes actually query for 15 rows only and returns PaginatedList.
1) Your jsp will look like this
Note that it specified the sort is external.
2) org.displaytag.pagination.PaginatedList implementation.
3) DAO Implementation sample using hibernate. You can do it with JDBC or anything but make sure you're making the right query to get 15 rows in proper order and return PaginatedListImpl object.