• sangigup
  • NEWBIE
  • 0 Points
  • Member since 2010

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

Hello Gurus,

 

I have a VisualForce page that is calling a Custom StandardSetController with Pagination. I go to page #2 and update a record. After I hit save, I am directed back to first page although {!CurrentPage} displays Page #2. How can I stay on the current record/Page after I hit save?

Here is the relevant code:

 

Controller code:

public with sharing class SMADummy {
    
public ApexPages.StandardSetController setCon {
    get {
        if (setCon== null){
            system.debug('Calling locator');
        setCon=new ApexPages.StandardSetController(Database.getQueryLocator(
                            [Select s.Name, Activity_Start_Date__c,Activity_End_Date__c From Dummy__c s order by name limit 30]));
                 
                
               
            }
            return setCon;
        }
        set;
    }
   public List<Smart_Marketing_Activity__c> getActivities() {
     
         return (List<Smart_Marketing_Activity__c>) setCon.getRecords();
 }

 

VF Code:

<apex:page controller="SMADummy">

<apex:form>

<apex:pageBlock>

    <apex:pageBlockButtons >
            
                <apex:CommandButton value="Save" action="{!save}" />
              
              </apex:pageBlockButtons>
          

  <apex:commandLink action="{!setCon.previous}" immediate="true" >Previous</apex:commandlink>
    <apex:commandLink action="{!setCon.next}" immediate="true">Next</apex:commandlink>
     <apex:pageBlockTable value="{!Activities}" var="SMA" >

 

 <apex:column >
               <apex:facet name="header">Activity Start Date</apex:facet>
               <apex:inputField value="{!SMA.Activity_Start_Date__c}" />
            </apex:column>

....

....

 </apex:pageBlockTable>
      
     </apex:pageBlock>
  </apex:form>

</apex:page>

Hello Gurus,

 

I have a VisualForce page that is calling a Custom StandardSetController with Pagination. I go to page #2 and update a record. After I hit save, I am directed back to first page although {!CurrentPage} displays Page #2. How can I stay on the current record/Page after I hit save?

Here is the relevant code:

 

Controller code:

public with sharing class SMADummy {
    
public ApexPages.StandardSetController setCon {
    get {
        if (setCon== null){
            system.debug('Calling locator');
        setCon=new ApexPages.StandardSetController(Database.getQueryLocator(
                            [Select s.Name, Activity_Start_Date__c,Activity_End_Date__c From Dummy__c s order by name limit 30]));
                 
                
               
            }
            return setCon;
        }
        set;
    }
   public List<Smart_Marketing_Activity__c> getActivities() {
     
         return (List<Smart_Marketing_Activity__c>) setCon.getRecords();
 }

 

VF Code:

<apex:page controller="SMADummy">

<apex:form>

<apex:pageBlock>

    <apex:pageBlockButtons >
            
                <apex:CommandButton value="Save" action="{!save}" />
              
              </apex:pageBlockButtons>
          

  <apex:commandLink action="{!setCon.previous}" immediate="true" >Previous</apex:commandlink>
    <apex:commandLink action="{!setCon.next}" immediate="true">Next</apex:commandlink>
     <apex:pageBlockTable value="{!Activities}" var="SMA" >

 

 <apex:column >
               <apex:facet name="header">Activity Start Date</apex:facet>
               <apex:inputField value="{!SMA.Activity_Start_Date__c}" />
            </apex:column>

....

....

 </apex:pageBlockTable>
      
     </apex:pageBlock>
  </apex:form>

</apex:page>