[SalesForce] How to reload the entire VF page after inline editing on apex:detail

I have a visualforce page that overrides the View on the Opportunity object. The VF page itself doesn't do a lot, however it has a controller that checks the state of the Opportunity and will redirect the user to another page in certain cases, such as based on Stage, etc. This is done via the action= attribute on the apex:page tag. This all works great when the Opp is viewed, or if the user clicks the [Edit] button to edit the Opportunity full screen, and then clicks [Save].

    <!-- Display the Main Opportunity Page -->
<apex:detail subject="{!Opportunity.Id}" rendered="{!Opportunity.Id != null}" relatedList="True" 
    showChatter="True" inlineEdit="true"  />

Where it breaks is when the user double-clicks on a field to use Inline Editing. After the user clicks [Save] in Inline Editing mode, the Opportunity detail section appears to be re-rendered (I'm assuming that because the content updates accordingly). However, in order for our custom logic to work, the page has to be completely reloaded after the Save so the controller can check he Opportunity Stage and take the necessary action.

I've tried a few different tricks to get the page to reload, but nothing has worked so far:

  • Add an "onComplete=" attribute to apex:detail. The documentation implies this gets run after the detail section re-renders, but I found that it did nothing.
  • Use jQuery to append JS to Salesforce's [Save] button. The onlick action on that button is easily retrievable via j$(".btn[name='inlineEditSave']").attr('onclick');, however adding window.reload(true); after the call to save() doesn't work either.

Has any one been able to successfully get the page to completely reload after inline editing completes?

Best Answer

Well, I've just tried the following code on my org with a newest Chrome and Firefox version and it reloads the entire page after save:

<apex:page standardController="Opportunity">

    <apex:detail subject="{!Opportunity.Id}" 
                 rendered="{!Opportunity.Id != null}" 
                 relatedList="True" 
                 showChatter="True" 
                 inlineEdit="true"
                 oncomplete="location.reload()"/>

</apex:page>
Related Topic