View Full Version : Paging in Spring
Arvind_A
Sep 11th, 2006, 02:17 AM
Hi ,
I have a case where i need to use paging ... Can anyone help me out with an tags that i need to use to display paging like
Prev 1 2 3 4 5 Next
And a controller class that "implements Controller" will be useful for me..??
Thanks in advance
Arvind.A
Sam Brannen
Sep 12th, 2006, 11:46 AM
Hi Arvind,
First off, this is the Spring Modules forum. If you have generic questions such as this one, you should post to one of the core Spring forums or the Spring MVC forum.
I have a case where i need to use paging ... Can anyone help me out with an tags that i need to use to display paging like
Prev 1 2 3 4 5 Next
And a controller class that "implements Controller" will be useful for me..??
AFAIK, there are no specific tags to assist you with this, nor is there a specific controller to achieve this directly; however, there are support classes in the Spring core that can help you out.
In the org.springframework.beans.support package, you'll find the following classes: PagedListHolder, PagedListSourceProvider, RefreshablePagedListHolder, SortDefinition, MutableSortDefinition, etc.
I won't go into detail on how to use them, because there is already a great working example which is packaged with the Spring distribution. See the "countries" example (path: samples/countries/*), specifically the CountriesController and CountriesFilter classes. That should give you a good idea of how you can use these classes.
I'd like to point out one other small detail: you can use a PagedListHolder in place of a standard Form Backing Object or Command Object when used in conjunction with a FormController. Thus, when implementing a custom paging solution, you would set your custom command object to be the filter on the PagedListHolder. The CountriesFilter serves exactly this purpose in the example.
Hope this helps,
Sam
Arvind_A
Sep 12th, 2006, 11:33 PM
Thanks Sam,
I posted the Paging query in this because I saw a query related to Spring in this section of the Forum . I did have a look at the countries Sample , I was actually looking for two things. One whether RefreshablePagedListHolder would help me in fetching dynamic queries in case the records in the table are changed . And secondly if we have an option of using any other display tags in the jsp .
Thanks for the input Sam
Sam Brannen
Sep 13th, 2006, 07:51 AM
One whether RefreshablePagedListHolder would help me in fetching dynamic queries in case the records in the table are changed.
I'm not really sure what you mean by "helping" you. If there are changes in the underlying list source, you will obviously need to determine that somehow on your own. You can use the refresh() method to reload the list from the source provider at appropriate times/intervals.
And secondly if we have an option of using any other display tags in the jsp.
Spring does not limit what JSP tag libs you use. So if you want to implement paging with a third-party tag lib such as the DisplayTag (http://displaytag.sourceforge.net/11/) or something similar, you can certainly do that, but that is standard Java/JSP and thus has nothing to do with Spring directly.
regards,
Sam
Arvind_A
Sep 14th, 2006, 01:32 AM
Yeh I had already tried out the with the Spring tlds which is somewhat like this :
<c:if test="${!productList.firstPage}">
<a href="?name=previous"><font color="Red"><B><< PrevLink</B></font></a>
</c:if>
</td> ...
<td> <c:forEach begin="${productList.firstLinkedPage}" end="${productList.lastLinkedPage}" var="crtpg">
<c:choose>
<c:when test="${crtpg == productList.page}">
<font color='red'><c:out value="${crtpg+1}"/></font></A>
</c:when>
<c:otherwise>
<a href="?name=<c:url value="${crtpg}"></c:url>">  <c:out value="${crtpg+1}"/></a>
</c:otherwise>
</c:choose>
</c:forEach>
</td>
<td>
<c:if test="${!productList.lastPage}">
<a href="?name=next"><font color="Red"><B>NextLink >></B></font></a>
</c:if>
</td>
<td>
</td>
</tr>
</table>
and for the refreshing part I had used refreshablePagedListHolder.setSource(prodManDetail s.getProductsDAO()); in the cases required ....
But I just wondered if The DisplayTags would make my case simpler
Hi ,
I have a case where i need to use paging ... Can anyone help me out with an tags that i need to use to display paging like
Prev 1 2 3 4 5 Next
And a controller class that "implements Controller" will be useful for me..??
Thanks in advance
Arvind.A
Powered by vBulletin® Version 4.2.1 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.