I havea custom save button on a visualforce page as below. I wanted to use actionstatus to show the user that the save process was taking place/in progress. However recently the redirect stopped for me, then looking at the debug logs I noticed the {!onSave} action was taking place twice.

            <apex:actionStatus id="saveCart">
                <apex:facet name="stop">
                    <apex:commandButton action="{!onSave}" value="Save" status="saveCart" reRender="msgs"/>

                <apex:facet name="start">
                    <apex:outputPanel >
                        <apex:image value="/img/loading32.gif" style="height: 15px"/>
                        <apex:commandButton value="Saving..." status="saveCart" disabled="true"/>

The onSave action as defined in my extension is:

public PageReference onSave(){

    catch(Exception e){
        return null;                

catch(Exception e){
    return null;
    }  // to allow formatting of lost lines

return new PageReference('/' + ApexPages.currentPage().getParameters().get('Id'));

I've removed the action status and stripped the save button down to the below, and this works - the {!onSave} action only gets called once and the page redirects. But as soon as I add a reRender parameter it fails to redirect again...what could cause this? And how can I get the actionstatus back in?

 <apex:commandButton action="{!onSave}" value="Save"/>

I've ruled out the browser (same behavior occurred on IE, FF and Chrome) and tried on a different instance (CS8 and CS14).

  • 1
    One thing to note, unrelated to the question, it's bad practice for maintainability to reference Salesforce resources (/img/loading32.gif) in your custom pages. If you plan to use the "loading" image, you should save a copy of the gif in a Static Resource and reference it from there instead. – Mark Pond Dec 11 '14 at 17:52

Sounds similar to an issue I faced - there are a couple of answers worth trying, but I think it is using the status with a PageBlockButton that seems to cause the issue...if you take it out of the pageblock markup, does it still fire twice?

  • Yes that's stopped the action being called twice but with no page redirection upon completion. I'll go through the linked post/answers and report back. Thanks for the link. – Girbot Dec 11 '14 at 18:52
  • Ha. Just turned off development mode/view state and the redirection has worked. – Girbot Dec 11 '14 at 18:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.