function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
R@v!R@v! 

pagination is not working properly

//Apex Class

public class ManagePhasescontroller {
    Public Integer count {get; set;}
    Public Integer countRecord {get; set;}
    public boolean bCounter {get;set;}
    Public Integer benchSize {get; Set;}
    public string para{get;set;}

 public void getselectedbenchmark() {
     try{
         if(MonthAcc.Account__c !=null && selectedPhase != null)
         selectedbenchmark = [SELECT Responsible__c,Date_Completed__c,Target_Date__c,Objective__c,Phase__c,Sequence__c from Phase_Benchmark__c where Phase__r.Account__c=:MonthAcc.Account__c AND  Phase__c = :selectedPhase.Id  AND Completed__c=false ORDER BY Sequence__c ASC]; 
        if(selectedbenchmark!=null  && selectedbenchmark.size()>0){
        benchSize = selectedbenchmark.size(); 
        }
            count = 0;
            countRecord = 1;
            bCounter = true;
        }
         catch (Exception e){}
    }
    
    
     //**Method for incement the counter
     public PageReference incrementCounter() {
        
            count++;
         
             countRecord++;
           
             bCounter = false;
      
         return null;
    }
    
    //**Method for decrement the counter
    public PageReference decrementCounter() {
      
            count--;
      
            countRecord--;
   
            return null;
    }
    
    //**Method for fetch count value
    public Integer getCount() { 
        return count;
    }



//VF Page


<apex:outputPanel id="thePanel">
                                <apex:outputPanel styleClass="red" rendered="{!if(selectedPhase!=null,true,false)}" >
                                    <apex:pageBlockSection title="Phase Information">
                                        <apex:outputField value="{!selectedPhase.Phase_Number__c}"/> 
                                        <apex:outputField value="{!selectedPhase.Description__c}"/>
                                        <apex:outputField value="{!selectedPhase.Start_Date__c}"/>
                                        <apex:outputField value="{!selectedPhase.End_Date__c}"/>
                                    </apex:pageBlockSection><br/>
                                    <apex:outputPanel rendered="{!if(selectedbenchmark=null,true,false)}" >
                                        <center> All Benchmark for this Phase have been Completed.<br/><br/>
                                            <apex:commandButton value="Move to Next Phase" action="{!movenextphase}" reRender="MonthlyFrm"/>
                                        </center>
                                    </apex:outputPanel>
                                   </apex:outputPanel>
                                </apex:outputPanel><br/>
                                <apex:outputPanel id="Panel">
                                <apex:repeat value="{!selectedbenchmark}" var="bench" id="theRepeat" rows="1" first="{!if(count=-1,0 ,count)}">
                                    <apex:outputPanel styleClass="red"  rendered="{!if(selectedbenchmark!=null,true,false)}">
                                   
                                       <apex:pageBlockSection title="Phase BenchMark">
                                         
                                            <apex:outputField value="{!bench.Responsible__c}"/> 
                                            <apex:outputField value="{!bench.Target_Date__c}"/>
                                            <apex:outputField value="{!bench.Objective__c}"/>
                                            <apex:outputField value="{!bench.Date_Completed__c}"/>  
                                          
                                       </apex:pageBlockSection><br/>    
                                    <apex:outputPanel >
                                   <center>  
                                 
                                   <apex:outputpanel id="panel2">
                   
                                    <apex:commandButton value="<<" rerender="btn2" disabled="{!if((bCounter=true || count=0),true ,false)}"/>
                                    <apex:actionSupport id="btn2" event="onclick" action="{!decrementCounter}" rerender="panel,panel2,out,panel1"/>
                                        
                                    </apex:outputpanel>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                    <apex:outputPanel >
                                    <apex:commandButton value="Complete this Benchmark" action="{!completebenchmark}" reRender="MonthlyFrm,Panel">
                                    <apex:param value="{!bench.Id}" assignTo="{!para}"/></apex:commandButton>
                                    </apex:outputPanel>
                                    &nbsp;&nbsp;&nbsp;&nbsp;<apex:outputText value="{!countRecord}" id="out"/>/{!benchSize}&nbsp;&nbsp;&nbsp;&nbsp;
                                    <apex:outputpanel id="panel1">
                                    <apex:commandButton value=">>" rerender="btn1" disabled="{!if(countRecord=benchSize,true ,false)}"/>
                                    <apex:actionSupport id="btn1" event="onclick" action="{!incrementCounter}" rerender="Panel,panel2,out,panel1"/>
                                    </apex:outputpanel>
                                                                   
                                                                  
                                </center>
                            </apex:outputPanel>                             
                        </apex:outputPanel>
                       </apex:repeat>
                    </apex:outputPanel>

 
Mehul MakwanaMehul Makwana
Hi,

You can use below Syntax for pagination,
<!-- Pagination -->
<table style="width: 100%"><tr>

    <td>
        <!-- Page X of Y -->
    </td>            

    <td align="center">
        <!-- Previous page -->
        <!-- Next page -->
    </td>
    
    <td align="right">
        <!-- Records per page -->
    </td>

</tr></table>
You can also refer working code describe as below,
 
<!-- Pagination -->
<table style="width: 100%"><tr>

    <td>
        Page: <apex:outputText value=" {!PageNumber} of {! CEILING(ResultSize / PageSize) }"/>
    </td>            

    <td align="center">
        	<!-- Previous page -->
	<!-- active -->
	<apex:commandLink action="{! Previous }" value="« Previous"
     	rendered="{! HasPrevious }"/>
	<!-- inactive (no earlier pages) -->
	<apex:outputText style="color: #ccc;" value="« Previous"
     	rendered="{! NOT(HasPrevious) }"/>

	&nbsp;&nbsp;  

	<!-- Next page -->
	<!-- active -->
	<apex:commandLink action="{! Next }" value="Next »"
     	rendered="{! HasNext }"/>
	<!-- inactive (no more pages) -->
	<apex:outputText style="color: #ccc;" value="Next »"
     	rendered="{! NOT(HasNext) }"/>
    </td>
    
    <td align="right">
        Records per page:
	<apex:selectList value="{! PageSize }" size="1">
   	  <apex:selectOption itemValue="5" itemLabel="5"/>
    	  <apex:selectOption itemValue="20" itemLabel="20"/>
    	  <apex:actionSupport event="onchange" reRender="contacts_list"/>
	</apex:selectList>
    </td>

</tr></table>

mark it as answer If it helps you.