+ Start a Discussion
jdk4702jdk4702 

How do I create "Page X of Y" like List Views?

I'm stuck trying to actually set the set controller page number - my best try simply refreshes the page, leaving the page unchanged.

 

VF Snippet:

 

 

Page <apex:inputText value="{!pageNum}">
                        <apex:actionSupport event="onchange" action="{!setPageNum}"/>
                    </apex:inputText> 
                of "{!totalPages}"

 Controller snippet:

 

 

public Integer pageNum{
        get{
            return setCon.getPageNumber();
        }//get
        set;
    }//pageNum

    public Integer totalPages{ 
        get{
            Integer numPages =setCon.getResultSize()/setcon.getPageSize();
            if(numPages*setcon.getPageSize()!=setCon.getResultSize()){
                numPages++;
            }//if 
            return numPages;
        }//get
        set;
    }//total pages

    public void next() {
        setCon.next();
    }//next
    
    public void previous() {
        setCon.previous();                
    }//previous

    public void setPageNum(){
        setCon.setPageNumber(pageNum);
    }//setPageNum

 

Perhaps pageNum does the "get" method when setPageNumber() tries to get the changed value and resets it to the "unchanged" value?

 

Thx for the help!

 

 

sravusravu

//Try the following to get the page number

public String pageParam {

          get {

                 if (pageParam == null) {

                                         pageParam = paramByParamId(PARAM_PAGE, '1');

                     }

                 return pageParam;

          }

          set;

 }   

//Try the following to get the total number of pages

 

 Integer totalNumPages = Math.round(Math.ceil(controller.getResultSie() / ( 1.0 * controller.getPageSize())));

 

 

Let me know if you face any difficulty


Hope this helps you..........

jdk4702jdk4702

Thanks for the response sravu!  I wasn't able to figure out what you meant below though.

 

What should "paramByParamId" do?  This isn't a standard VF, Apex, or HTML method.

 

My primary issue is trying to set the page of the controller by using an input box, which I haven't been able to figure out yet.

 

Thanks for the help!

sravusravu

it will give you the current page number