Results 1 to 4 of 4

Thread: Making a server call when closing browser (GXT 2.3)

  1. #1
    Sencha Premium User
    Join Date
    Jun 2011
    Posts
    76

    Default Making a server call when closing browser (GXT 2.3)

    When the user closes the browser or navigates away from the page I need to make a server call to log the user off.

    I've attempted to do this in the viewport onUnload and also on the Detach event.

    Whilst these are being called, my subsequent server insn't invoked and I get socket exceptions when closing the browser.

    Is there some way to acheive this? Possibly intercept the detach/close, make the server call and continue on return.

    Thanks

  2. #2
    Sencha Sr Product Manager
    Join Date
    Jan 2012
    Location
    Arlington, WA
    Posts
    1,178

    Default

    From what it sounds like you could use the Window.addCloseHandler to do what you need.

    Only register this somewhere in the app.
    Code:
      Window.addWindowClosingHandler(new ClosingHandler() {
          @Override
          public void onWindowClosing(ClosingEvent event) {
            System.out.println("Browser is closing");
          }
        });
    Would this help you get closer to the goal?

  3. #3
    Sencha Premium User
    Join Date
    Jun 2011
    Posts
    76

    Default

    That seems a bit better than handling in the viewport events.

    I can handle the move away condition reliably now but the browser close still fails to complete.

    I tried using the setMessage to prompt for confirmation but that seems to take control away from the app so I don't get a chance to make the server call and close the browser on return.

    I'll play around with it a bit more and see if I get anywhere.

    Thanks for your help.

  4. #4
    Sencha Sr Product Manager
    Join Date
    Jan 2012
    Location
    Arlington, WA
    Posts
    1,178

    Default

    Unfortunately it is impossible to prevent the browser closing. At most the dialog can be asked are you sure you want to move away, but in some cases this is not possible if the window is closed by exiting.

    Maybe a persistent connection could be used and when the broke have the server log the user out.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •