+ Start a Discussion
Arvind010Arvind010 

how to update the fields on closing the window?

In a visual force page, on closing the window,  fields in the page should be updated.How to call the method in the controller using oncose java script function?is there any possibility to implement without javascript?

Ron HessRon Hess
I don't think you can do this with the onclick event of the window, at least i could not get it to work either


Message Edited by Ron Hess on 10-06-2008 04:31 PM
Arvind010Arvind010
I gave the javascript function in the actionFunction component.Code is
Code:
<apex:actionFunction name="onclose" action="{!onclose}" />

I called this function in the script while closing the window.Script code is
Code:
<script language="JavaScript">
   function window.onunload()
    {
      alert("window.onClose works!");
      window.setTimeout(onclose,100);      
      alert("window.onClose works1!");
    }        
</script>
When i close the window, two alert boxes are getting displayed.But the onclose function is not getting called and the fields are not getting updated.Controller code is

Code:
public PageReference onclose()
    {
        system.debug('onclose');        
        Contact objContactSFDCStatus = [Select Status_SFDC_Contact__c from Contact where id=:id1];        
        objContactSFDCStatus.Status_SFDC_Contact__c = 'Delete';
        Update objContactSFDCStatus;
        return null;                 
    }
Please provide me the solution.
 

 



Message Edited by Arvind010 on 09-18-2008 02:05 AM
Chirag MehtaChirag Mehta

Any updates on above, we too are facing issue of calling Apex Function on unload window event.