You need to sign in to do that
Don't have an account?
Naveen Bharadwaj
Onstop() method is not called in VisualForce page
I have a Command button in my VisualForce page, clicking on it would popup a new page. After entering the details and clicking on Save, popup window will close and refresh the parent page. I found some code and tried to replicate the same in my page. Below is my code to popup the new window:
<apex:pageBlockSection title="Create New Account" columns="3">
<apex:commandButton value="Create New Account" onclick="popupNew();" reRender="accTable"/>
</apex:pageBlockSection>
function popupNew(){
var newwindow = window.open('/apex/AddAccount','Add account', target='_blank');
newwindow.focus();
return false;
}
When I click on Save in the popup window, I'm doing this:
<apex:commandButton action="{!quicksave}" value="Save" status="closer" reRender="qId,accTable" timeout="1000" rendered="true" /> <apex:actionStatus id="closer" startText="Saving.." stopText="" onstop="refreshPage();" rendered="true"></apex:actionStatus>
function refreshPage(){
window.top.close();
window.opener.location.href="/apex/Account_Contact_Layout";
window.opener.location.reload(true);
}
The problem here is refreshPage() function is not getting called at all. If I use onstart="refreshPage()" instead of onstop="" it is getting called. What am I missing here?
P.S: The problem with onstart="" is that the window closes as soon as I click on Save button and immediately refreshes the parent page. Save happens in the background when the page has started refreshing already. So, I will have to refresh the page manually again to see my results, which makes no sense.
<apex:pageBlockSection title="Create New Account" columns="3">
<apex:commandButton value="Create New Account" onclick="popupNew();" reRender="accTable"/>
</apex:pageBlockSection>
function popupNew(){
var newwindow = window.open('/apex/AddAccount','Add account', target='_blank');
newwindow.focus();
return false;
}
When I click on Save in the popup window, I'm doing this:
<apex:commandButton action="{!quicksave}" value="Save" status="closer" reRender="qId,accTable" timeout="1000" rendered="true" /> <apex:actionStatus id="closer" startText="Saving.." stopText="" onstop="refreshPage();" rendered="true"></apex:actionStatus>
function refreshPage(){
window.top.close();
window.opener.location.href="/apex/Account_Contact_Layout";
window.opener.location.reload(true);
}
The problem here is refreshPage() function is not getting called at all. If I use onstart="refreshPage()" instead of onstop="" it is getting called. What am I missing here?
P.S: The problem with onstart="" is that the window closes as soon as I click on Save button and immediately refreshes the parent page. Save happens in the background when the page has started refreshing already. So, I will have to refresh the page manually again to see my results, which makes no sense.
All Answers
Kidding. Thanks for the help. Just what I wanted.