function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Jonny.KatesJonny.Kates 

Getting a commandButton to refresh the WHOLE page on {!save}

I'm working on a VisualForce page for a custom object. I have apex form inputfields within a styled HTML table to suit the preferred UI layout of the client. Underneath the table is a commandButton for the form, which will action {!save} when clicked. It successfully writes the data from the inputfields - no problem. But when clicked, it just refreshes the iframed VF page element. The result is that the whole page-layout for the object is refreshsed within the embedded VisualForce page, whilst the 'parent' page - the original browser if you will - remains unchanged.

 

How can I make the commandButton commit the inputfields, and then refresh the browser?

 

Hope I've explained that clear enough - can try and capture it in screen shots if needed.

Damien_Damien_

I'm not completely sure what you mean but I'll cover 2 scenarios that it could be.

 

1)  You have a command button that just refreshes the page instead of a section.

 

Wrap your page in 

<apex:outputPanel id="myRerender">
  <!-- Rest of your page in here
  Your apex:page and apex:form components should NOT be in here
  -->
  <apex:commandButton value="Save" action="{!save}" rerender="myRerender" />
</apex:outputPanel>

 

 

 2) You have a custom VF page embedded in a frame of another page.

<apex:commandButton value="Save" action="{!save}" oncomplete="window.opener.location.refresh();" />

 It might actually be window.opener.location.reload() instead.  I haven't used this for a few months.

 

 

Jonny.KatesJonny.Kates

The javascript is reload() - either way, that doesn't work for what I'm trying to achieve.

 

The table and save button are in a VisualForce page, embedded in the page layout of the custom object:

http://i.imgur.com/Uo2qL.png

 

When I hit save, it successfully writes the data from the VForce page to the controlling record, but then just refreshes the embedded frame of the VisualForce page:

http://i.imgur.com/idSWA.png

 

 

I want the behaviour of the save button to replicate that of the normal 'Save' button at the top or bottom of the page layout. I can't just rely on these normal save button as it only appears once a field has new data pending to be saved; 'orange' data.

Damien_Damien_

Hmmmm, are you currently using a controller for this or just a VF page?

 

If you are using an extension, this MIGHT work.

 

private ApexPages.StandardController cont;

public MyController(ApexPages.StandardController controller)
{
  cont = controller;
}

public PageReference save()
{
  //Do work here
  return cont.save();
}

 I'm not completely sure it will work.  It might just redirect you to this page within the frame, but if we are using the controllers save, hopefully it might refer to the parents save and then do what you want.

 

Alternatively, window.opener.window.opener.reload(); or window.opener.opener.reload(); might partially work for what you want.

 

If these don't work, I may be out of ideas for you.