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
JesseAJesseA 

Inline VF page that opens windows and can be refreshed

I'm sure this information is on this board, i've read a few posts about similar stuff but not sure how to go forward.

 

I have a VF page which I am showing inline on a record detail. Along with showing information it has a button that when pressed opens a different page in a new window like this:

 

    <script language="javascript">
        function newWindow(file,window)
        {
          msgWindow=open(file,window,'scrollbars=yes,resizable=yes,width=960,height=600');
          if (msgWindow.opener=null)
          msgWindow.opener = self;
        }        
    </script>

     .....
    <apex:commandButton onclick="newWindow('/apex/editCountries?id={!targetId}','editdwindow');"  value="Edit Countries" />

 

On the page that is shown in the new window, editCountries, a user can update fields and there is a button to save on that page which saves the updates and closes the window:

 

 

<apex:commandButton action="{!save}" value="Save" id="theButton" onclick="self.close();"/>

The updates work fine and the window closes but how can i change this so that the original page, the one that has the button to call the second page gets refreshed when the Save button is clicked on the second page?

 

Both pages use seperate controllers.  

 

Thanks,

Jesse

Best Answer chosen by Admin (Salesforce Developers) 
Pradeep_NavatarPradeep_Navatar

You can refresh the window on oncomplete event of commandbutton and call the javascript function to refresh the window :

 

<apex:commandbutton/>

<script>

function refresh(){window.parent.location.replace('/{!$CurrentPage.parameters.id}');}

</script>

All Answers

Damien_Damien_

The only way I can think is to use an action poller on the originally page.  Each time it activates check to see if there has been changes made and if so refresh the specific section of the page with it.  As far as I can know there is not a great solution to your problem.

JesseAJesseA

I actually have gotten it to work, although not as cleanly as I would like. Its not 100% because sometimes the refresh happens quicker than the updates that are being made to the data shown. Your idea of the action poller might actually work because it has that interval attribute. Thanks I'll try it out today.

 

Edit: I might have to make my two pages/contollers into one so that i can make use of the action poller.

Pradeep_NavatarPradeep_Navatar

You can refresh the window on oncomplete event of commandbutton and call the javascript function to refresh the window :

 

<apex:commandbutton/>

<script>

function refresh(){window.parent.location.replace('/{!$CurrentPage.parameters.id}');}

</script>

This was selected as the best answer
JesseAJesseA

!!!! You are the man Pradeep. Thank you so much. 

Seema27Seema27

Hi,

 

Can you post your code for command button ? Am also facing same issue.. but i have written onclick on main page command button.. so can not write oncomplete event again.. am got stuck here..

 

Thanks,

Seema