How to refresh the parent page after a Save action in a Visualforce page embedded in a page layout?

  • I am trying to complete a VF page section that my sales-staff will be utilizing to add information to custom fields when a condition is met inside of the Account object. I have the custom page built and deposited into the account layout; but my final hurdle is what happens when the VF section is saved. When the 'Save' command button is clicked, the entire page is deposited into the VF section. The VF page when accessed directly works perfectly; it's only when the section is used inside of the larger page layout is the 'window inside window' effect seen. An F5 rectifies this; and returns the section back to normal but I cannot for the life of me figure out how to avoid this extra step. I modeled the code after this example found on developerforce:

    Any help would be appreciated.

  • Rao

    Rao Correct answer

    7 years ago

    From the recipe change the save button from

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


    <apex:commandLink value="Save" action="{!save}" 
        target="_parent" styleClass="btn" 

    Since commandlink offers a target attribute I make use of it and make the command link exactly like the button using styleclass and style attributes

    I tried even the command button with onclick approach but the child page constantly reloaded with the side bar and headers and did not look like it was inline. The commandlink is something I have worked hence the solution above, but it could be done using commandbutton if tweaked a bit more. Since we have what is required I did not push futher:)

    @Ian Allison please mark it solved when you get some time :)

    This works @Rao, thanks. Only thing I'm struggling with is to NOT open in the _parent target if validation errors come back.

    I've posted my twist on your answer to handle form errors,, thanks!

License under CC-BY-SA with attribution

Content dated before 7/24/2021 11:53 AM