• anupamaaj1.3905395811417727E12
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 1
    Replies
Hi,

I have stuck in a more complex situation for the simple thing.

I have a component to construct the pageblock table , That component is called by command button in visualforce page my code is as below ....
Sorry in advance to show this big code...

VF Code :
========================

<apex:page controller="RetrieveArchivedRecords" sidebar="False">
   
    <apex:form id="theForm">   
        <apex:commandButton value="displayTable" rerender="callComponent,thePgBlock" action="{!fetchData}" id="displayData"/>
    </apex:form>   
   
    <apex:outputPanel id="callComponent">
   
        <c:DynamicObjectTable ObjectName="Case" rendered="{!showResults}"
            FieldsetName="Test" DetailFields="DetailFieldsSet"
            JSONData="{!GetJsonData}"
            Title="Archived Cases"
            TablePageSize="6"
        />
       
    </apex:outputPanel>
   
   
</apex:page>

Apex Code:
===============
From class i m sending the json data


My Component
==================

<apex:component controller="DynamicObjectTableController">

    <apex:attribute name="FieldsetName"  assignTo="{!strFieldSetName}" type="String" required="true" Description="Fieldset name"/>
    <apex:attribute name="DetailFields"  assignTo="{!innerFieldSet}" type="String" required="true" Description="Fieldset name"/>
    <apex:attribute name="ObjectName"  assignTo="{!strObjectName}" type="String"  required="true" description="Object name"/>
    <apex:attribute name="TablepageSize"  assignTo="{!Pagesize}" type="Integer"  required="true" description="Object name" default="10"/> 
    <apex:attribute name="JSONData"  assignTo="{!strObjectJSON}"  type="String" required="true"  description="data list"/>
    <apex:attribute name="Title"   type="String" required="true" description="Title of the pageblock table"/>

<!----    <apex:attribute name="Reload"  assignTo="{!isControllerInitialized}" type="Boolean" required="false" description="test" default="false" /> --->
// If I remoce the above line the pagination is working good, but command button of visualforce is not taking the recent value (command button not working properly) and if I add the aboce code , the paginatin buttons are not working but the command button in VF page is working .
        <apex:form >
            <apex:pageBlock title="{!Title}" id="thePgBlock">
           
                    <apex:pageblocktable value="{!DisplayedObjects}" var="r" id="ArchivedTableID">
                        <apex:column headerValue="Show">
                            <apex:commandbutton image="/img/func_icons/cal/rightArrow.gif" action="{!showSelectedRecord}" rerender="ArchivedTableID,ArchivedDetailId">
                                <apex:param name="rowid" value="{!r.Id}" assignTo="{!selectedRecordId}"/>
                            </apex:commandbutton>
                        </apex:column>
                        <apex:repeat value="{!fieldSetMembers}" var="f">
                            <apex:column value="{!r[f]}"/>
                        </apex:repeat>

                   
                   
                    <apex:facet name="header" >
                            <apex:outputpanel layout="block" >
                                <apex:commandButton value="First"  title="First Page" reRender="ArchivedTableID" action="{!First}" status="FetchStatus"  disabled="{!hasNoPrevious}"/>
                                <apex:commandButton value="Previous"  title="Previous Page" reRender="ArchivedTableID" action="{!Previous}" status="FetchStatus"   disabled="{!hasNoPrevious}"/>
                                <apex:outputText >{!(pageNumber * pagesize)+1-pagesize}-{!IF((pageNumber * pagesize)>noOfRecords, noOfRecords,(pageNumber * pagesize))} of {!noOfRecords}</apex:outputText>
                                <apex:commandButton value="Next"  title="Next Page" reRender="ArchivedTableID" action="{!Next}" status="FetchStatus" disabled="{!hasNoNext}"/>
                                <apex:commandButton value="Last"  title="Last Page" reRender="ArchivedTableID" action="{!Last}" status="FetchStatus" disabled="{!hasNoNext}"/>
                            </apex:outputpanel>
                    </apex:facet>
                   
                    <apex:facet name="footer" >
                            <apex:outputpanel layout="block" >
                                <apex:commandButton value="First"  title="First Page" reRender="ArchivedTableID" action="{!First}" status="FetchStatus"  disabled="{!hasNoPrevious}"/>
                                <apex:commandButton value="Previous"  title="Previous Page" reRender="ArchivedTableID" action="{!Previous}" status="FetchStatus"   disabled="{!hasNoPrevious}"/>
                                <apex:outputText >{!(pageNumber * pagesize)+1-pagesize}-{!IF((pageNumber * pagesize)>noOfRecords, noOfRecords,(pageNumber * pagesize))} of {!noOfRecords}</apex:outputText>                       
                                <apex:commandButton value="Next"  title="Next Page" reRender="ArchivedTableID" action="{!Next}" status="FetchStatus" disabled="{!hasNoNext}"/>
                                <apex:commandButton value="Last"  title="Last Page" reRender="ArchivedTableID" action="{!Last}" status="FetchStatus" disabled="{!hasNoNext}"/>
                            </apex:outputpanel>
                    </apex:facet>  
                   
                 </apex:pageblocktable> 
                
            </apex:pageBlock>    

    </apex:form>

            <apex:pageblock title="Details" id="ArchivedDetailId" rendered="{!showSelectedDetailRecord}">
                <apex:pageblocksection >
                    <apex:repeat value="{!InnerFieldSetMembers}" var="f">
                        <apex:outputField value="{!selectedRecord[f]}"/>
                    </apex:repeat>
                </apex:pageblocksection>

                   
            </apex:pageblock>     


<!--------------------------------------------------------------------->
   
</apex:component>


Controller for above component
==================================
public with sharing class DynamicObjectTableController
{

   


    //=========component attributes =====

    public String   strObjectJSON{get;set;}
    public String strobjectName{get;set;}
    public String strfieldSetName{get;set;}
    public String innerFieldSet{get;set;}
    transient public Schema.FieldSet  fieldSetDetails{get;set;}
    public Integer pagesize {get;set;}
   
    private Schema.SObjectType   objType;
   
    //=====var declaration
   
        public ApexPages.StandardSetController  scon{get;set;}
        public boolean isControllerInitialized {get;set;}
        public SObject selectedObject {get;set;}
        public List<SObject> displayedObjectList {get;set;}
       
        Public Integer NoOfRecords{get; set;}
   
    //========================

    public DynamicObjectTableController ()
    {
        System.debug('**** Entered inside the Controller construction ****');
        isControllerInitialized=false;
        showSelectedDetailRecord =false;
        System.debug('**** Done with controller construction ****');
    }
   
    public void initTestData()
    {
        System.debug('**** Inside initTestData ****');
        strobjectName = 'Case';
        strfieldSetname = 'Test';
        innerFieldSet = 'DetailFieldsSet';
        System.debug('**** Finished  initTestData method ****');
    }
   
   
      
    public List<Schema.FieldSetMember> getFieldSetMembers()
    {
        System.debug('**** Entered getFieldSetMembers Method ****');
        objType = (Schema.SObjectType) Schema.getGlobalDescribe().get(strobjectName);
        Schema.DescribeSObjectResult d = objType.getDescribe();
        fieldSetDetails = d.fieldSets.getMap().get(strfieldSetName);
        System.debug('**** Finished getFieldSetMembers Method ****' +fieldsetDetails.getFields());
        System.debug('**** fieldsetDetails.getFields() : ' +fieldsetDetails.getFields());
        return  fieldsetDetails.getFields();
       
       
    }
   
    public List<Schema.FieldSetMember> getInnerFieldSetMembers()
    {
        System.debug('**** Entered getInnerFieldSetMembers ****');
        objType = (Schema.SObjectType) Schema.getGlobalDescribe().get(strobjectName);
        Schema.DescribeSObjectResult d = objType.getDescribe();
        fieldSetDetails = d.fieldSets.getMap().get(innerFieldSet);
        System.debug('**** Finished getInnerFieldSetMembers  fieldsetDetails.getFields() : ' + fieldsetDetails.getFields());
       
        return  fieldsetDetails.getFields();
       
       
    }
   

   
    public Map<String,SObject>  recMap {get;set;}
    public String selectedRecordId {get;set;}
   
    public List<SObject> getDisplayedObjects()
    {
        System.debug('**** Entered getDisplayedObjects ****');
       
        if(isControllerInitialized == false)
        {
               System.debug('**** Inside getDisplayedObjects -- if statemnet : value of isControllerInitialized :' + isControllerInitialized);
                scon = new ApexPages.StandardSetController(getAllObjects());
                NoOfRecords=scon.getResultSize();
                scon.setPageSize(pageSize);               
                System.debug('**** NoOfRecords : ' + NoOfRecords);              
               isControllerInitialized =true;
        }
        System.debug('**** Came out of if stmt. ****');
        displayedObjectList = scon.getRecords()  ;       

        recmap = new Map<String,SObject>();
       
        for( SObject rec : scon.getRecords())
        {
            recmap .put(rec.Id, rec);
        }
       
        //show the first record by default
        if(displayedObjectList.size() >0)
        {
            showSelectedDetailRecord = true;
            selectedRecordId = displayedObjectList[0].Id;
            showSelectedDetailRecord =true;
        }

        return scon.getRecords();
       
    }
   
    public Case selectedRecord {get;set;}
    public boolean showSelectedDetailRecord {get;set;}
   
   
    /* public String[] getFieldNames ()
    {
        return new string[] {'CaseNumber', 'ClosedDate'};
    }*/
   
    public void showSelectedRecord()
    {
        System.debug('**** Entered showSelectedRecord Method ***** ');
        selectedRecord = (Case) recmap.get(selectedRecordId);
       
        if(selectedRecord !=null)
            showSelectedDetailRecord =true;
        else
            showSelectedDetailRecord  = false;
        System.debug('**** Finished showSelectedRecord method , showSelectedDetailRecord : ' +showSelectedDetailRecord);   
      
           
    }
 
     Type objListdatatype;
   
    public List<SObject>  getAllObjects()
    {
        System.debug('**** Entered getAllObjects method ***' );
        objListdatatype = Type.forName('List<'+strobjectName+'>');

        List<Sobject> Allcaselist;
          
        try{
                System.debug('**** Entered getAllObjects method try stmt .***' ); 
              /*   String casestr= '[';
                 for(integer i=0;i<10;i++)
                 {
                     casestr += '{"CaseNumber":"111-'+i+'", "Origin":"Email", "ClosedDate":"2012-02-15T19:03:32-08:00", "Reason":"Feedback"}';
                     if(i<9) casestr+=',';
                 }
                 casestr+=']'; */
                 AllcaseList =  (List<SObject>) (List<SObject>) JSON.deserializeStrict(strObjectJSON, objListdatatype);          
                

        }
        catch(Exception e)
        {
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error, e.getMessage()));
        }
        System.debug('**** Finished getAllObjects method try stmt , allcaselist : ' +allcaselist );
        return allcaselist;
       
      
    }
   
    public void showSelectedObject()
    {
        if( displayedObjectList .size() >0)
        {
            selectedObject = displayedObjectList[0];
            showSelectedDetailRecord  = true;
           
        }
    }
   

//=====================Navigation Methods ==============
  
public Boolean hasNoNext {      
     get {
       System.debug('**** Has no Next??? ****' + ! sCon.getHasNext());         
     return ! sCon.getHasNext();   
     }     
     set;
    } 
     public Boolean hasNoPrevious {    
         get { 
             System.debug('**** Has no Previous??? ****' + ! sCon.getHasPrevious());      
         return ! sCon.getHasPrevious();   
         }       
         set;  
     }   
     public Integer pageNumber {      
         get {   
             System.debug('**** pg # ****' + sCon.getPageNumber());
             return sCon.getPageNumber();    
            
         }     
         set;  
     }    
     public void first() {
            
        sCon.first();  
     }
    
     public void last() { 
     System.debug('***** Clicked on Last button *****');  
        sCon.last();  
     }  
     public void previous() {     
        sCon.previous();  
     }    
     public void next() {  
         System.debug('***** Clicked on next button , Number of records ' +noofrecords + ' pagesize' +pagesize);
         System.debug('***** number of records : ' +noofrecords);
        
        sCon.next();
     }  
  }

Please help me to get all the buttons working . i.e pagination buttons(First,Previous,next,last ) and VF Command button should work
Hi,

For adding the item in a selectlist we do the following

for(String f :  FieldLabels)
        {
             selectedFieldsList.add(new selectOption(f,f));        
       
        }
and this works perfect.

Same way how to remove from the select list ? I dtried with the following things and got the errors

E.g : 1 : for(String f : selectedFields)
        {
             selectedFieldsList.remove(f);           
        }
ERROR :  Method does not exist or incorrect signature: [LIST<System.SelectOption>].remove(String)

for(integer i=0;i<selectedFields.Size();i++)
        {
                      selectedFieldsList.remove(selectedFields.Size());
        }
ERROR : LIST INDEX OUT OF BONDS

for(String f : selectedFields)
        {
         
           selectedFieldsList.remove(0); 
          
        }

here the items are deleted but , if i select 5 random items to delete, it is removing first 5 items not the selected one.
Hi,

I have stuck in a more complex situation for the simple thing.

I have a component to construct the pageblock table , That component is called by command button in visualforce page my code is as below ....
Sorry in advance to show this big code...

VF Code :
========================

<apex:page controller="RetrieveArchivedRecords" sidebar="False">
   
    <apex:form id="theForm">   
        <apex:commandButton value="displayTable" rerender="callComponent,thePgBlock" action="{!fetchData}" id="displayData"/>
    </apex:form>   
   
    <apex:outputPanel id="callComponent">
   
        <c:DynamicObjectTable ObjectName="Case" rendered="{!showResults}"
            FieldsetName="Test" DetailFields="DetailFieldsSet"
            JSONData="{!GetJsonData}"
            Title="Archived Cases"
            TablePageSize="6"
        />
       
    </apex:outputPanel>
   
   
</apex:page>

Apex Code:
===============
From class i m sending the json data


My Component
==================

<apex:component controller="DynamicObjectTableController">

    <apex:attribute name="FieldsetName"  assignTo="{!strFieldSetName}" type="String" required="true" Description="Fieldset name"/>
    <apex:attribute name="DetailFields"  assignTo="{!innerFieldSet}" type="String" required="true" Description="Fieldset name"/>
    <apex:attribute name="ObjectName"  assignTo="{!strObjectName}" type="String"  required="true" description="Object name"/>
    <apex:attribute name="TablepageSize"  assignTo="{!Pagesize}" type="Integer"  required="true" description="Object name" default="10"/> 
    <apex:attribute name="JSONData"  assignTo="{!strObjectJSON}"  type="String" required="true"  description="data list"/>
    <apex:attribute name="Title"   type="String" required="true" description="Title of the pageblock table"/>

<!----    <apex:attribute name="Reload"  assignTo="{!isControllerInitialized}" type="Boolean" required="false" description="test" default="false" /> --->
// If I remoce the above line the pagination is working good, but command button of visualforce is not taking the recent value (command button not working properly) and if I add the aboce code , the paginatin buttons are not working but the command button in VF page is working .
        <apex:form >
            <apex:pageBlock title="{!Title}" id="thePgBlock">
           
                    <apex:pageblocktable value="{!DisplayedObjects}" var="r" id="ArchivedTableID">
                        <apex:column headerValue="Show">
                            <apex:commandbutton image="/img/func_icons/cal/rightArrow.gif" action="{!showSelectedRecord}" rerender="ArchivedTableID,ArchivedDetailId">
                                <apex:param name="rowid" value="{!r.Id}" assignTo="{!selectedRecordId}"/>
                            </apex:commandbutton>
                        </apex:column>
                        <apex:repeat value="{!fieldSetMembers}" var="f">
                            <apex:column value="{!r[f]}"/>
                        </apex:repeat>

                   
                   
                    <apex:facet name="header" >
                            <apex:outputpanel layout="block" >
                                <apex:commandButton value="First"  title="First Page" reRender="ArchivedTableID" action="{!First}" status="FetchStatus"  disabled="{!hasNoPrevious}"/>
                                <apex:commandButton value="Previous"  title="Previous Page" reRender="ArchivedTableID" action="{!Previous}" status="FetchStatus"   disabled="{!hasNoPrevious}"/>
                                <apex:outputText >{!(pageNumber * pagesize)+1-pagesize}-{!IF((pageNumber * pagesize)>noOfRecords, noOfRecords,(pageNumber * pagesize))} of {!noOfRecords}</apex:outputText>
                                <apex:commandButton value="Next"  title="Next Page" reRender="ArchivedTableID" action="{!Next}" status="FetchStatus" disabled="{!hasNoNext}"/>
                                <apex:commandButton value="Last"  title="Last Page" reRender="ArchivedTableID" action="{!Last}" status="FetchStatus" disabled="{!hasNoNext}"/>
                            </apex:outputpanel>
                    </apex:facet>
                   
                    <apex:facet name="footer" >
                            <apex:outputpanel layout="block" >
                                <apex:commandButton value="First"  title="First Page" reRender="ArchivedTableID" action="{!First}" status="FetchStatus"  disabled="{!hasNoPrevious}"/>
                                <apex:commandButton value="Previous"  title="Previous Page" reRender="ArchivedTableID" action="{!Previous}" status="FetchStatus"   disabled="{!hasNoPrevious}"/>
                                <apex:outputText >{!(pageNumber * pagesize)+1-pagesize}-{!IF((pageNumber * pagesize)>noOfRecords, noOfRecords,(pageNumber * pagesize))} of {!noOfRecords}</apex:outputText>                       
                                <apex:commandButton value="Next"  title="Next Page" reRender="ArchivedTableID" action="{!Next}" status="FetchStatus" disabled="{!hasNoNext}"/>
                                <apex:commandButton value="Last"  title="Last Page" reRender="ArchivedTableID" action="{!Last}" status="FetchStatus" disabled="{!hasNoNext}"/>
                            </apex:outputpanel>
                    </apex:facet>  
                   
                 </apex:pageblocktable> 
                
            </apex:pageBlock>    

    </apex:form>

            <apex:pageblock title="Details" id="ArchivedDetailId" rendered="{!showSelectedDetailRecord}">
                <apex:pageblocksection >
                    <apex:repeat value="{!InnerFieldSetMembers}" var="f">
                        <apex:outputField value="{!selectedRecord[f]}"/>
                    </apex:repeat>
                </apex:pageblocksection>

                   
            </apex:pageblock>     


<!--------------------------------------------------------------------->
   
</apex:component>


Controller for above component
==================================
public with sharing class DynamicObjectTableController
{

   


    //=========component attributes =====

    public String   strObjectJSON{get;set;}
    public String strobjectName{get;set;}
    public String strfieldSetName{get;set;}
    public String innerFieldSet{get;set;}
    transient public Schema.FieldSet  fieldSetDetails{get;set;}
    public Integer pagesize {get;set;}
   
    private Schema.SObjectType   objType;
   
    //=====var declaration
   
        public ApexPages.StandardSetController  scon{get;set;}
        public boolean isControllerInitialized {get;set;}
        public SObject selectedObject {get;set;}
        public List<SObject> displayedObjectList {get;set;}
       
        Public Integer NoOfRecords{get; set;}
   
    //========================

    public DynamicObjectTableController ()
    {
        System.debug('**** Entered inside the Controller construction ****');
        isControllerInitialized=false;
        showSelectedDetailRecord =false;
        System.debug('**** Done with controller construction ****');
    }
   
    public void initTestData()
    {
        System.debug('**** Inside initTestData ****');
        strobjectName = 'Case';
        strfieldSetname = 'Test';
        innerFieldSet = 'DetailFieldsSet';
        System.debug('**** Finished  initTestData method ****');
    }
   
   
      
    public List<Schema.FieldSetMember> getFieldSetMembers()
    {
        System.debug('**** Entered getFieldSetMembers Method ****');
        objType = (Schema.SObjectType) Schema.getGlobalDescribe().get(strobjectName);
        Schema.DescribeSObjectResult d = objType.getDescribe();
        fieldSetDetails = d.fieldSets.getMap().get(strfieldSetName);
        System.debug('**** Finished getFieldSetMembers Method ****' +fieldsetDetails.getFields());
        System.debug('**** fieldsetDetails.getFields() : ' +fieldsetDetails.getFields());
        return  fieldsetDetails.getFields();
       
       
    }
   
    public List<Schema.FieldSetMember> getInnerFieldSetMembers()
    {
        System.debug('**** Entered getInnerFieldSetMembers ****');
        objType = (Schema.SObjectType) Schema.getGlobalDescribe().get(strobjectName);
        Schema.DescribeSObjectResult d = objType.getDescribe();
        fieldSetDetails = d.fieldSets.getMap().get(innerFieldSet);
        System.debug('**** Finished getInnerFieldSetMembers  fieldsetDetails.getFields() : ' + fieldsetDetails.getFields());
       
        return  fieldsetDetails.getFields();
       
       
    }
   

   
    public Map<String,SObject>  recMap {get;set;}
    public String selectedRecordId {get;set;}
   
    public List<SObject> getDisplayedObjects()
    {
        System.debug('**** Entered getDisplayedObjects ****');
       
        if(isControllerInitialized == false)
        {
               System.debug('**** Inside getDisplayedObjects -- if statemnet : value of isControllerInitialized :' + isControllerInitialized);
                scon = new ApexPages.StandardSetController(getAllObjects());
                NoOfRecords=scon.getResultSize();
                scon.setPageSize(pageSize);               
                System.debug('**** NoOfRecords : ' + NoOfRecords);              
               isControllerInitialized =true;
        }
        System.debug('**** Came out of if stmt. ****');
        displayedObjectList = scon.getRecords()  ;       

        recmap = new Map<String,SObject>();
       
        for( SObject rec : scon.getRecords())
        {
            recmap .put(rec.Id, rec);
        }
       
        //show the first record by default
        if(displayedObjectList.size() >0)
        {
            showSelectedDetailRecord = true;
            selectedRecordId = displayedObjectList[0].Id;
            showSelectedDetailRecord =true;
        }

        return scon.getRecords();
       
    }
   
    public Case selectedRecord {get;set;}
    public boolean showSelectedDetailRecord {get;set;}
   
   
    /* public String[] getFieldNames ()
    {
        return new string[] {'CaseNumber', 'ClosedDate'};
    }*/
   
    public void showSelectedRecord()
    {
        System.debug('**** Entered showSelectedRecord Method ***** ');
        selectedRecord = (Case) recmap.get(selectedRecordId);
       
        if(selectedRecord !=null)
            showSelectedDetailRecord =true;
        else
            showSelectedDetailRecord  = false;
        System.debug('**** Finished showSelectedRecord method , showSelectedDetailRecord : ' +showSelectedDetailRecord);   
      
           
    }
 
     Type objListdatatype;
   
    public List<SObject>  getAllObjects()
    {
        System.debug('**** Entered getAllObjects method ***' );
        objListdatatype = Type.forName('List<'+strobjectName+'>');

        List<Sobject> Allcaselist;
          
        try{
                System.debug('**** Entered getAllObjects method try stmt .***' ); 
              /*   String casestr= '[';
                 for(integer i=0;i<10;i++)
                 {
                     casestr += '{"CaseNumber":"111-'+i+'", "Origin":"Email", "ClosedDate":"2012-02-15T19:03:32-08:00", "Reason":"Feedback"}';
                     if(i<9) casestr+=',';
                 }
                 casestr+=']'; */
                 AllcaseList =  (List<SObject>) (List<SObject>) JSON.deserializeStrict(strObjectJSON, objListdatatype);          
                

        }
        catch(Exception e)
        {
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error, e.getMessage()));
        }
        System.debug('**** Finished getAllObjects method try stmt , allcaselist : ' +allcaselist );
        return allcaselist;
       
      
    }
   
    public void showSelectedObject()
    {
        if( displayedObjectList .size() >0)
        {
            selectedObject = displayedObjectList[0];
            showSelectedDetailRecord  = true;
           
        }
    }
   

//=====================Navigation Methods ==============
  
public Boolean hasNoNext {      
     get {
       System.debug('**** Has no Next??? ****' + ! sCon.getHasNext());         
     return ! sCon.getHasNext();   
     }     
     set;
    } 
     public Boolean hasNoPrevious {    
         get { 
             System.debug('**** Has no Previous??? ****' + ! sCon.getHasPrevious());      
         return ! sCon.getHasPrevious();   
         }       
         set;  
     }   
     public Integer pageNumber {      
         get {   
             System.debug('**** pg # ****' + sCon.getPageNumber());
             return sCon.getPageNumber();    
            
         }     
         set;  
     }    
     public void first() {
            
        sCon.first();  
     }
    
     public void last() { 
     System.debug('***** Clicked on Last button *****');  
        sCon.last();  
     }  
     public void previous() {     
        sCon.previous();  
     }    
     public void next() {  
         System.debug('***** Clicked on next button , Number of records ' +noofrecords + ' pagesize' +pagesize);
         System.debug('***** number of records : ' +noofrecords);
        
        sCon.next();
     }  
  }

Please help me to get all the buttons working . i.e pagination buttons(First,Previous,next,last ) and VF Command button should work