How to override Save method in standard controller extension?

I am wriiting a extension on Case object. There I want to write a save method with my own logic and want this save method should override the standard Save method.

So my code goes like below:

public class MyCaseControllerExt {

    private final Case caseObj;

    // get Case record from the standard controller and putting it in a member variable
    public MyCaseControllerExt (ApexPages.StandardController stdController) {
        this.caseObj = (Case)stdController.getRecord();

    public override PageReference save(){
        // TO DO
        return null;



But, while saving the class, I am getting 1 error :

Save error: MyCaseControllerExt : Method does not override an ancestor
method: System.PageReference save()

So my question is how we will override the existing Save method in extension class?


You don’t use the override keyword in this case, as you aren’t extending another class and overriding its methods in a classical object oriented situation. Instead, the Visualforce platform adheres to a contract that it will look for a method in your extension named ‘Save’ first, and if it doesn’t find that it will fallback to the method in the standard controller. This all happens automatically, so all you need to do is define your save method:

public PageReference save(){
    // TO DO
    return null;


Source : Link , Question Author : SFDC Geek , Answer Author : Bob Buzzard

Leave a Comment