[ http://jira.codehaus.org/browse/DISPL-225?page=comments#action_43772 ]
Eugene Clark commented on DISPL-225:
------------------------------------
There is a simpler way to resolve this issue. In
SmartListHelper.getPageNavigationBar:
old: startPage = Math.max(Math.min(this.currentPage - groupSize / 2,
this.pageCount - groupSize), 1);
new: startPage = Math.max(Math.min(this.currentPage - groupSize / 2,
this.pageCount - groupSize + 1), 1);
Index: SmartListHelper.java
===================================================================
RCS file:
/usr/local/cvsroot/displaytag/src/java/org/displaytag/pagination/SmartListHelper.java,v
retrieving revision 1.1
diff -u -r1.1 SmartListHelper.java
--- SmartListHelper.java 10 Jun 2005 13:16:00 -0000 1.1
+++ SmartListHelper.java 2 Aug 2005 13:32:09 -0000
@@ -282,7 +282,7 @@
// center the selected page, but only if there are {groupSize} pages
available after it, and check that the
// result is not < 1
- startPage = Math.max(Math.min(this.currentPage - groupSize / 2,
this.pageCount - groupSize), 1);
+ startPage = Math.max(Math.min(this.currentPage - groupSize / 2,
this.pageCount - groupSize + 1), 1);
endPage = Math.min(startPage + groupSize - 1, this.pageCount);
if (log.isDebugEnabled())
> The group_size property is reflected as the total number of pages in the
> reports using pagination plus the last page doesnt show up in the links of
> pages
> ---------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: DISPL-225
> URL: http://jira.codehaus.org/browse/DISPL-225
> Project: DisplayTag
> Type: Bug
> Components: Paging/Sorting
> Versions: 1.0
>
> Original Estimate: 2 days
> Remaining: 2 days
>
> Problem 1: I tried using the value '{5} of {6}' for the properties:
> paging.banner.full, paging.banner.last and paging.banner.full. According to
> the documentation of display tags, {5} represents the current page and {6}
> represents the total number of pages. BUT the output from using these value
> is: {5} represents the current page and {6} represents the group size. The
> group size property was specified using the property
> paging.banner.group_size. So, instead of showing the total number of pages
> the value {6} showed the number of pages specified for a group.
> Problem 2: The other problem that I was faced with was related to link for
> the last page. If I have n pages to show, then the display tag allowed to
> show only n-1 pages. So i never end up seeing the nth page in my report.
> Solution
> To solve this problem I had to go ahead with modification of the two files:
> SmartListHelper.java and Pagination.java.
> SmartListHelper.java modifications:
> Method : getPageNavigationBar
> Earlier code : endPage = Math.min(startPage + groupSize - 1, this.pageCount);
> Modified code : endPage = Math.min(startPage + groupSize - 1, this.pageCount);
> The value of endPage is calculated in such a way that it will have a maximum
> value of n-1, where n is the total number of pages. I modified this code to
> ensure that the link to the last page is also generated. This is not a good
> solution ( but it works for me ) because if you have to work with this code,
> you will need to specify the (group size - 1) value in the
> displaytag.properties file i.e., if you want a group size of 5, you need to
> specify it 4.
> Method: getPageNavigationBar
> Earlier code : if (this.currentPage != this.pageCount)
> Modified code: if(this.currentPage <= this. pageCount)
> The earlier if statement will NEVER set the 'last page' and the modified if
> statement will set the last page.
> This modification prompted me to change the concept of 'last page' in
> Pagination class. The Pagination class in display tag library uses the
> following code to determine the last page:
> public boolean isLast()
> {
> return this.lastPage == null;
> }
> The lastPage is defined as an Integer type and is set null for the last page.
> I changed the code to make it more realistic: the last page is the page whose
> count is equal to pageCount.
> public boolean isLast()
> {
> return currentPage.intValue() == pageCount;
> }
> This required adding the following instance variable inside the Pagination
> class: private int pageCount and the following setter method:
> public void setPageCount(int i)
> {
> pageCount = i;
> }
> The setPageCount method is called by the SmartListHelper class in its
> getPageNavigationBar method :
> Pagination pagination = new Pagination(href, s);
> pagination.setCurrent(new Integer(currentPage));
> As I mentioned the value of {6} was taken as the value of the group size.
> This required changes in the Pagination class' getFormattedBanner method.
> Earlier:
> Object[] pageObjects = {
> numberedPageString,
> ((Href) this.href.clone()).addParameter(this.pageParam,
> getFirst()),
> ((Href) this.href.clone()).addParameter(this.pageParam,
> getPrevious()),
> ((Href) this.href.clone()).addParameter(this.pageParam,
> getNext()),
> ((Href) this.href.clone()).addParameter(this.pageParam,
> getLast()),
> this.currentPage,
> new Integer(pages.size())};
> The last argument decides the total number of pages to be shown corresponding
> to the value {6}. The pages.size() corresponds to the value of group size,
> which is wrong. It should correspond to the last page, therefore the modified
> code now looks like:
> Object[] pageObjects = {
> numberedPageString,
> ((Href) this.href.clone()).addParameter(this.pageParam,
> getFirst()),
> ((Href) this.href.clone()).addParameter(this.pageParam,
> getPrevious()),
> ((Href) this.href.clone()).addParameter(this.pageParam,
> getNext()),
> ((Href) this.href.clone()).addParameter(this.pageParam,
> getLast()),
> this.currentPage,
> getLast()};
> Please let me know in case of any queries.
> Regards
> Ashish Sarin, Kanbay
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
displaytag-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/displaytag-devel