1 Reply Latest reply on Oct 5, 2006 1:55 AM by Srihari_Ainumpudi

    Handling browser close in Flex

    Srihari_Ainumpudi
      Hi,

      My requirement is when i close the browser, from javascript i want to
      call java application using HttpService in Flex Application.
      I am using FABridge to call java application using HttpService from
      javaScript.

      JavaScript code snippet
      ----------------------------------

      var flexApp = null;
      var initCallback = function()
      {
      flexApp = FABridge.flash.root();
      }
      FABridge.addInitializationCallback("flash",initCallback);


      function saveChanges() {
      if (flexApp!= null) {
      var dataChangedFlag = flexApp.dataChangedFlag();
      if(dataChangedFlag) {
      var closeWin = window.confirm("Do you want to save your changes?");
      if (true) {
      flexApp.httpService.request.reqParamMode="saveChanges";
      flexApp.setUnSavedDataAsXML();
      flexApp.httpService.send();
      flexApp.closeWindow();
      alert('done...');
      }
      }
      }

      Code is failing to identify httpService object.

      If any one know's any other mechanism to handle browser close also
      fine. Some how i want to call java application to save changes i made
      in flex application when browser is closed.


      Is it possible to handle browser closing using FABridge or not .........
      If any have tried the same, reply me soon.........................................
      very very urgent......................

      Regards,
      SriHari
        • 1. Re: Handling browser close in Flex
          Srihari_Ainumpudi Level 1
          Hey guys,

          finally i found a solution for calling java Application from JavaScript using FABridge.

          flexApp.httpService.request.reqParamMode="saveChanges";
          flexApp.setUnSavedDataAsXML();
          flexApp.httpService.send();

          I moved all the above statements into a method in my application.mxml file.

          function void closeWindow():void{
          httpService.request.reqParamMode="saveChanges";
          setUnSavedDataAsXML();
          httpService.send();
          }

          Calling the above method in JavaScript

          function saveChanges() {
          if (flexApp!= null) {
          var dataChangedFlag = flexApp.dataChangedFlag();
          if(dataChangedFlag) {
          flexApp.closeWindow();
          alert('done...');
          }
          }
          }

          ------SriHari