ICEfaces
  1. ICEfaces
  2. ICE-11555

Add proper support for the confirmation dialog before closing a window

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: EE-4.3.0.GA_P04, EE-3.3.0.GA_P10
    • Component/s: Bridge
    • Labels:
      None
    • Environment:
      Any

      Description

      A supported customer recently contacted us to ask how could they show a confirmation dialog before closing a window. While we provided the javascript code to accomplish that, one problem remained: When the user confirms that they want to leave the page the 'window.dispose' action is not triggered.

      We tried to come up with a workaround, but it wasn't possible to accomplish this without modifying the bridge code. The javascript function that triggers this action is simply not exposed to be called by ICEfaces application developers, and the parameters needed to call this function are not easily accessible either. So, we need to add proper support for this use case of showing the confirmation dialog when closing a window and triggering the `window.dispose` action if the user confirms that they want to leave the page.

        Activity

        Hide
        Arturo Zambrano added a comment -

        For reference, this is the code necessary to display the confirmation dialog to leave a page, bypassing the listeners to dispose of the view:

            <script type="text/javascript">
                window.addEventListener('beforeunload', function (e) {
                    console.log('test');
                    e.stopImmediatePropagation();
                    e.preventDefault();
                    e.returnValue = '';
                }, true);
            </script>
        
        Show
        Arturo Zambrano added a comment - For reference, this is the code necessary to display the confirmation dialog to leave a page, bypassing the listeners to dispose of the view: <script type="text/javascript"> window.addEventListener('beforeunload', function (e) { console.log('test'); e.stopImmediatePropagation(); e.preventDefault(); e.returnValue = ''; }, true); </script>
        Hide
        Arturo Zambrano added a comment -

        Adding proper support for the confirmation dialog before closing a window or navigating away from the current page (i.e. beforeunload event) was attempted, but, unfortunately, browsers currently don't offer the necessary behaviour and hooks to support this properly in ICEfaces. The intention was to be able to react to the user's answer to the confirmation dialog before leaving a page. If they decide to stay on the page, the page's state shouldn't change, and if they decide to leave the page, the window dispose and tear down methods should be executed before the page is closed. While it's possible to support the first case, when the user stays on the page, it's not possible to fully support the second case, when the user leaves the page. This is in part because it's not possible to execute most javascript calls on the page after the user answers that they want to leave the page. Certain javascript functions are allowed to execute by the browsers, but it's not possible to execute all the code that's necessary to gracefully leave the page in this use case. While it's still possible to execute some of this code, there's no simple and reliable way to do it.

        Show
        Arturo Zambrano added a comment - Adding proper support for the confirmation dialog before closing a window or navigating away from the current page (i.e. beforeunload event) was attempted, but, unfortunately, browsers currently don't offer the necessary behaviour and hooks to support this properly in ICEfaces. The intention was to be able to react to the user's answer to the confirmation dialog before leaving a page. If they decide to stay on the page, the page's state shouldn't change, and if they decide to leave the page, the window dispose and tear down methods should be executed before the page is closed. While it's possible to support the first case, when the user stays on the page, it's not possible to fully support the second case, when the user leaves the page. This is in part because it's not possible to execute most javascript calls on the page after the user answers that they want to leave the page. Certain javascript functions are allowed to execute by the browsers, but it's not possible to execute all the code that's necessary to gracefully leave the page in this use case. While it's still possible to execute some of this code, there's no simple and reliable way to do it.

          People

          • Assignee:
            Arturo Zambrano
            Reporter:
            Arturo Zambrano
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: