Monday, April 16, 2012

How to implement “Cancel” functionality in a VisualForce Page

Apex Class:

public class sampleExtension {

  ApexPages.standardController std = null;

  public sampleExtension(ApexPages.standardController sc)  {
    std = sc;
  }

  public PageReference doCancel()  {
    return std.cancel();
  }
}

VisualForce Page:
<apex:commandButton action="{!doCancel}" value="Cancel"/>

Note: this doesn't necessarily take you to the list view, it'll return you to the last page you were viewing before going to the VF page.

Reference: 

No comments:

Post a Comment