3

I use a VF Component and it's embedded in an inline Visualforce page. I have a button called 'Submit' in the Component. I want to refresh the whole Object record page instead the Visualforce page when I click on 'Submit'. I tried giving the following, adding onclick="top.location.reload(true);" but it seems not to be working. Any help on this would be appreciated!

<apex:commandButton value="{!$Label.Submit_Button}" action="{!saveRatings}" onclick="top.location.reload(true);" />
  • 2
    One thing to be aware of is that the onclick will take place before your controller's action method is called and your saveRatings method may or may not be executed - depending on how quickly the refresh takes place while the browser is attempting to POST the data to the controller. Take a look at questions like this one for suggestions: salesforce.stackexchange.com/q/37036/660 – Mark Pond May 11 '15 at 16:01
1

Please try using,

window.top.location.reload();

The main problem is that inline page will be in visualforce domain(eg ap1.visualforce.com) and main page will be in salesforce domain(eg ap1.salesforce.com). There are security restrictions regarding cross domain javascript.

  • Tried this but still seems not working ! – Tinkerbell May 11 '15 at 15:54
  • 1
    Please check if developer mode is enabled. If it is enabled, please disable it and try. – Victor May 11 '15 at 16:12
1

This isn't possible, the platform will prevent the VF component from altering the detail page.

I don't know the specifics of your component, but maybe a Javascript button on the detail page which calls your controller code would work (as that WILL be able to reload the record page).

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.