Reputation:
I need to display the entries from one of my database table. Of course the data is huge, so I have to show the results on several pages, and that without getting all the data at once, but as the user navigates through the pages.
I wanted to use this plugin, but it seems to me that it needs to fetch all the data bedore applying pagination, is that right?? that's why I decided to look for another solution and then googling for a while I stumbled upon displaytag, and this what I'm using (or trying to use), but as I'm new at this I have a couple of doubts/problems :
Is there any way that, for example if I have 5000 rows to display, instead of getting all the 5000 in one go, just to fetch the first 20 that constitute the first page, assuming that's the page size, of course.
I'm using several stylesheets, as well as scripts on my site and everything works fine with displaytag, but only the first time you load the information, because when you click on any page numbers (from the pagination), the information is loaded correctly but all the styles, images and scripts just disappear and are no longer available, leaving the page completely blank, except for the static text, where am I going wrong or what am I doing wrong?
<display:table id="row" name="sessionScope.list" pagesize="20">
<display:column title="Date" >
<c:out value="${row.date}" />
</display:column>
<display:column title="Number" >
<c:out value="${row.number}" />
</display:column>
<display:column title="Number Plate" >
<c:out value="${row.numberPlate}" />
</display:column>
<display:setProperty name="paging.banner.onepage" value=" " />
</display:table>
I really hope you can help me out.
Thanks
Upvotes: 0
Views: 6320
Reputation: 355
an answer to #1:
You want to use what displayTag calls external sorting and paging. See this page for details http://www.displaytag.org/1.2/tut_externalSortAndPage.html
This will also help http://code.google.com/p/pagingappfuse/
Basically, you need to tell your database to limit the number of rows to return, and also count the total number of rows returned for that query. Then use display tag's page number and turn that into an offset for your database.
Upvotes: 1