You need to sign in to do that
Don't have an account?
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
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
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.
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.
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>
!!!! You are the man Pradeep. Thank you so much.
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