Redirecting Back to Previous Page Using Visualforce Page StandardController

Visualforce Page Button:

<apex:commandButton action="{!back}" value="Back"/>

Apex Controller:

public with sharing class ExampleController
{
    private ApexPages.StandardController sctrl;
    public SaveAndReturnController(ApexPages.StandardController stdController)
    {
        this.sctrl = stdController;
    }
 
    public PageReference back()
    {
        PageReference cancel = sctrl.cancel();
        return cancel;
    }
}

  • Imk

    thanks a lot