ICEfaces
  1. ICEfaces
  2. ICE-4217

Provide callback registering API for listening to connection and bridge specific events

    Details

    • Type: New Feature New Feature
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.8RC1
    • Fix Version/s: 1.8
    • Component/s: Bridge
    • Labels:
      None
    • Environment:
      supported browsers
    • Affects:
      Documentation (User Guide, Ref. Guide, etc.)

      Description

      Provide callback registering API for listening to connection and bridge specific events so that application developers can enhance UI experience or integrate with other third party JS libraries.

        Activity

        Hide
        Mircea Toma added a comment -

        Added bridge and connection event notification methods.

        Show
        Mircea Toma added a comment - Added bridge and connection event notification methods.
        Hide
        Mircea Toma added a comment - - edited

        Here are the provided event registration functions:

        Ice.onSendReceive(id, sendCallback, receiveCallback)
        id – the identifier of an element that is the parent or the child of the element owning the bridge instance (most of the time is the 'body' element)
        sendCallback – callback invoked when the request is initiated
        receiveCallback – callback invoked when response is received

        Ice.onAsynchronousReceive(id, callback)
        id – the identifier of an element that is the parent or the child of the element owning the bridge instance (most of the time is the 'body' element)
        callback – callback invoked when a push response is received

        Ice.onServerError(id, callback)
        id – the identifier of an element that is the parent or the child of the element owning the bridge instance (most of the time is the 'body' element)
        callback – callback invoked when server side error occurs, the callback gets the content/body of the response in its first parameter

        Ice.onSessionExpired(id, callback)
        id – the identifier of an element that is the parent or the child of the element owning the bridge instance (most of the time is the 'body' element)
        callback – callback invoked when session expired or it was invalidated

        Ice.onConnectionTrouble(id, callback)
        id – the identifier of an element that is the parent or the child of the element owning the bridge instance (most of the time is the 'body' element)
        callback – callback invoked when heartbeat pings are lost (asynchronous mode)

        Ice.onConnectionLost(id, callback)
        id – the identifier of an element that is the parent or the child of the element owning the bridge instance (most of the time is the 'body' element)
        callback – callback invoked when connection to server was lost

        Show
        Mircea Toma added a comment - - edited Here are the provided event registration functions: Ice.onSendReceive(id, sendCallback, receiveCallback) id – the identifier of an element that is the parent or the child of the element owning the bridge instance (most of the time is the 'body' element) sendCallback – callback invoked when the request is initiated receiveCallback – callback invoked when response is received Ice.onAsynchronousReceive(id, callback) id – the identifier of an element that is the parent or the child of the element owning the bridge instance (most of the time is the 'body' element) callback – callback invoked when a push response is received Ice.onServerError(id, callback) id – the identifier of an element that is the parent or the child of the element owning the bridge instance (most of the time is the 'body' element) callback – callback invoked when server side error occurs, the callback gets the content/body of the response in its first parameter Ice.onSessionExpired(id, callback) id – the identifier of an element that is the parent or the child of the element owning the bridge instance (most of the time is the 'body' element) callback – callback invoked when session expired or it was invalidated Ice.onConnectionTrouble(id, callback) id – the identifier of an element that is the parent or the child of the element owning the bridge instance (most of the time is the 'body' element) callback – callback invoked when heartbeat pings are lost (asynchronous mode) Ice.onConnectionLost(id, callback) id – the identifier of an element that is the parent or the child of the element owning the bridge instance (most of the time is the 'body' element) callback – callback invoked when connection to server was lost
        Hide
        Mircea Toma added a comment -

        For example, to show a popup on session expiry this is what is needed:

        .......
        <body id="document:body">
        <script type="text/javascript">
        Ice.onSessionExpired('document:body', function()

        { alert('Session has expired!'); }

        );
        </script>
        .......

        Show
        Mircea Toma added a comment - For example, to show a popup on session expiry this is what is needed: ....... <body id="document:body"> <script type="text/javascript"> Ice.onSessionExpired('document:body', function() { alert('Session has expired!'); } ); </script> .......
        Hide
        Tyler Johnson added a comment -

        I've tested the new onSessionExpiry method from the API and found the following:

        1. When session expires naturally, Ice.onSessionExpired() is called and everything works great.

        2. When I manually invalidate the session, the method is not called.

        Attached is a sample app that reproduces the issue. It is a facelets application intended for deployment on tomcat 6. Run the application and click login. This will popup a new screen with a logout button and graphic image. Try letting the session timout naturally (set at 1 minute) and you will see that the javascript alert is called and that the window is automatically close (window.self.close() in the javascript). What I've noticed is that if you click logout (which invalidates the session), the js is not called. The javascript is in the facelets template.jspx file.

        Show
        Tyler Johnson added a comment - I've tested the new onSessionExpiry method from the API and found the following: 1. When session expires naturally, Ice.onSessionExpired() is called and everything works great. 2. When I manually invalidate the session, the method is not called. Attached is a sample app that reproduces the issue. It is a facelets application intended for deployment on tomcat 6. Run the application and click login. This will popup a new screen with a logout button and graphic image. Try letting the session timout naturally (set at 1 minute) and you will see that the javascript alert is called and that the window is automatically close (window.self.close() in the javascript). What I've noticed is that if you click logout (which invalidates the session), the js is not called. The javascript is in the facelets template.jspx file.
        Hide
        Mircea Toma added a comment -

        The logout test case used for testing the JS listener is not the best suited test for this issue. The logout process creates a border case situation where the framework specifically chooses not to send the session expired message to avoid shutting down the bridge to early. If the bridge is shut down, the redirection to login page would not work anymore. This logout specific logic is implemented in the update coalescing policy.

        I recommend to change the test case so that redirection is not trigger, but only invalidate the session.

        Show
        Mircea Toma added a comment - The logout test case used for testing the JS listener is not the best suited test for this issue. The logout process creates a border case situation where the framework specifically chooses not to send the session expired message to avoid shutting down the bridge to early. If the bridge is shut down, the redirection to login page would not work anymore. This logout specific logic is implemented in the update coalescing policy. I recommend to change the test case so that redirection is not trigger, but only invalidate the session.

          People

          • Assignee:
            Unassigned
            Reporter:
            Mircea Toma
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: