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>
<apex:facet name="start">
<apex:outputPanel >
<apex:image value="/img/loading32.gif" style="height: 15px"/>
<apex:commandButton value="Saving..." status="saveCart" disabled="true"/>
</apex:outputPanel>
</apex:facet>
</apex:actionStatus>
The onSave action as defined in my extension is:
public PageReference onSave(){
if(forDeletion.size()>0)
try{
delete(forDeletion);
}
catch(Exception e){
ApexPages.addMessages(e);
return null;
}
try{
if(shoppingCart.size()>0)
upsert(shoppingCart);
}
catch(Exception e){
ApexPages.addMessages(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).
/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.