Currently in my VF Page (inline editing support enabled) after clicking "Save" button, I am being taken to the default detail page layout.

I want "Save" operation to be executed upon clicking the "Save" button but make the user stay on the same page.

Can someone tell what should I do ?

My Code :

<apex:page standardcontroller="Expense__c" sidebar="false" showHeader="true" showChat="false"  >
<apex:form >

<apex:inlineEditSupport />
<apex:commandButton action="{!save}" value="Save" id="theButton"/>
<apex:pageBlock title="List of Expenses">
<apex:pageBlockTable value="{!Expense__c}" var="item" >
<apex:column value="{!item.Date__c}"/>

<apex:column value="{!item.Type__c}"/>
<apex:column value="{!item.Amount__c}"/>
<apex:column value="{!item.Comments__c}"/>
  • Have you overridden the buttons in the salesforce configuration on the object?
    – Francis
    Commented Apr 13, 2014 at 10:09

1 Answer 1


It looks like your page invokes the standard controller's default save method that returns the default detail page URL. To change that URL you can write your own save method that first invokes the standard controller's save to do most of the work and then returns a page URL of your choosing:

public with sharing class ExpenseController {
    private ApexPages.StandardController sc;
    public ExpenseController(ApexPages.StandardController sc) {
        this.sc = sc;
    public PageReference save() {
        PageReference detailPage = sc.save();
        if (detailPage != null) {
            // Construct URL of edit page or whatever other page you want
            PageReference editPage = new PageReference(detailPage.getUrl() + '/e');
            return editPage;
        } else {
            return detailPage;

Include the name of the controller extension in the page:

<apex:page standardcontroller="Expense__c" extensions="ExpenseController" ...
  • Is it possible to have the quicksave function in the above code? That would be very handy too..
    – MnZ
    Commented Jun 19, 2014 at 4:49
  • 1
    @MnZ The standard controller has a quickSave method you can invoke from an extra "Quick Save" button.
    – Keith C
    Commented Jun 22, 2014 at 15:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .