+ Start a Discussion

pageblocktable pagination with wrapper class

Hi ,

I want to develop pagination for the pageblocktable with standardsetController. When I search online i m finding the codes where the standard controller and soql are used, as shown below...

private String baseQuery = 'Select ID, Name FROM Account ORDER BY NAME ASC';

public ApexPages.StandardSetController AccSetController {
            if(AccSetController == null){
                AccSetController = new ApexPages.StandardSetController(Database.getQueryLocator(baseQuery));

                // We have to set FilterId after Pagesize, else it will not work
                if(AccFilterId != null)
            return AccSetController;

but, in my case i m not using any soql, instead  I am using the wrapper classes . below is my code.

<apex:page controller="TablePaginationController">
    <apex:form >
    <apex:pageBlock >
          <apex:pageblockTable value="{!LinkedinCompanies}" var="linkedinComp" id="linkedinCompaniesTable">
                        <apex:column headerValue="id" value="{!linkedinComp.id}" />
                        <apex:column headerValue="name" value="{!linkedinComp.name}" />


public with sharing class TablePaginationController

    public List<companyDetails> data { get; set; }
     public ApexPages.StandardSetController setCon;


    public List<companyDetails> LinkedinCompanies{get;set;}
    public Class companyDetails
        public Integer id {get;set;}
        public String name {get;set;}
    public void linkedinSearch()
            String linkedinResponse = '{"companies": { "_count": 10, "_start": 0, "_total": 55556, "values": [ { "id": 10667, "name": "Facebook" }, { "id": 3748947, "name": "Community Management Facebook y Facebook Ads" }, { "id": 3219314, "name": "Smart Facebook Likes" }, { "id": 2620756, "name": "Revolucionamos Facebook" }, { "id": 3326206, "name": "Facebook-buy-fans.com" }, { "id": 2811427, "name": "Empowers Facebook Marketing for Business" }, { "id": 2226401, "name": "Facebook Advertising" }, { "id": 5059292, "name": "Facebook Covers" }, { "id": 3100592, "name": "Facebook Property Listing by propertybooster.com" }, { "id": 2453105, "name": "FaceBook Business Page Your Biz First" } ] }}';
            linkedinResponse = linkedinResponse.replace('"_', '"lin_');                
            Map<String, Object> linkedinRespCompanies = (Map<String, Object>) JSON.deserializeUntyped(linkedinResponse);          
            Map<String,Object> CompaniesMap = (Map<String,Object>)linkedinRespCompanies.get('companies');          
            String str = JSON.serialize(CompaniesMap.get('values'));                           
            List<companyDetails> LinkedinCompanies = (List<companyDetails>) JSON.deserializeStrict(str, List<companyDetails>.class);    
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFo,'' +LinkedinCompanies));
            data = LinkedinCompanies;
            catch(Exception e)
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'Exception' +e));

how do i develop pagination for this?

Please help.


Hi Anupama,

Please see if these links help:


If this answers your question, please mark this as the Best Answer for this post, so that others can benefit from this post.

You need to include the inbuilt pagination functions of the standardsetcontroller on the VF to show the pagination:

something similar to this on the block where you are populating records on the VF

<!-- Section to show display pagination for the Deal list -->
                        <apex:outputPanel style="position:absolute;margin-left:10cm;" id="grd">
                            <apex:commandButton status="fetchStatus" reRender="myPanel,grd" value="First |<" action="{!setCon.first}" disabled="{!!setCon.hasPrevious}" title="First Page"/>
                            <apex:commandButton status="fetchStatus" reRender="myPanel,grd" value="Previous <" action="{!setCon.previous}" disabled="{!!setCon.hasPrevious}" title="Previous Page"/>
                            <apex:outputText >{!(setCon.pageNumber)} of {!CEILING(noOfRecords/size)}</apex:outputText>
                            <apex:commandButton status="fetchStatus" reRender="myPanel,grd" value="Next >" action="{!setCon.next}" disabled="{!!setCon.hasNext}" title="Next Page"/>
                            <apex:commandButton status="fetchStatus" reRender="myPanel,grd" value="Last >|" action="{!setCon.last}" disabled="{!!setCon.hasNext}" title="Last Page"/>
Amit Chaudhary 8Amit Chaudhary 8
Hi Anupama,

If you are still looking for solution. Then Please check below blog :-

Amit Chaudhary