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    


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
displaytag-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/displaytag-devel

Reply via email to