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
John Neilan 2John Neilan 2 

CommandButton Refresh Page

I have a VF page with a commandbutton. I am trying to get the page to refresh once the commandbutton is clicked. The code below does what it is supposed to do, but the page does not refresh. Does anyone know how I can do this?
<apex:commandButton action="{!approve}" oncomplete="window.opener.location.refresh();" styleClass="buttonStyle" style="background:#99C299; font-size:16pt; font-family:arial;" value="Submit for Final Approval"/>
Pramodh KumarPramodh Kumar
use this oncomplete="location.reload()" instead of 
oncomplete="window.opener.location.refresh();"


Let me know if you have any issues.

Thanks,
pRAMODH.
Miroslav SmukovMiroslav Smukov
Hi, try to use the following approach:
 
<apex:commandButton action="{! someAction}" 
                                reRender="some_id" value="Test"/>

The key here is "reRender" property. This button will refresh the element with id="some_id". Try adding this ID to the element you want to refresh inside your page. If you want to refresh the whole page, try adding the ID to the top level element.

Let me know if it works?
Miroslav SmukovMiroslav Smukov
If the first approach I suggested doesn't work as expected, you can try the one below which I just tested:
 
<apex:commandButton value="Test"
                                onclick="location.reload();"/>

OnClick will call the JavaScript code that will reload the whole page.
 
John Neilan 2John Neilan 2
Thanks all.  I think my issue is that I have a workflow field update that updates a variable.  I would like the page to refresh automatically to show that update, but it seems that all the options I've tried update the page before the workflow field update occurs.  Any idea how to get the page to refresh after the WF update?