views:

155

answers:

1

It seems that CloseHandler and Window.ClosingHandler() are not working or are not triggering the events in the same way under IE as opposed to Firefox.

 Window.addWindowClosingHandler(new Window.ClosingHandler() {

                    @Override
                    public void onWindowClosing(ClosingEvent event) {
                        event.setMessage(message);

                    }




         Window.addCloseHandler(new CloseHandler<Window>() {

                    @Override
                    public void onClose(CloseEvent<Window> event) {
                        //Window.alert("debug1");
                        if(recordId!=null){


                            DatabaseQueryServiceAsync dbQueryService = DatabaseQueryService.Util.getInstance();
                            dbQueryService.releaseRecordLock(recordId, new AsyncCallback<String>() {

                                @Override
                                public void onFailure(Throwable arg0) {
                                }

                                @Override
                                public void onSuccess(String arg0) {

                                }
                            });



                        }
                    }


                });

                });

For example, the ClosingHandler under IE displays the message when I swap a panel within within my widget. This does not occur in Firefox.

The CloseHandler doesn't seem to trigger at all when the window closes in IE, but does so in firefox. The interesting thing to point out there, is that when I put a Window.alert("debug1") message in the addCloseHandler() method it DOES run the callback below, but as soon as I remove it, the callback doesn't happen. In firefox it works and runs the callback in both situations. So, I'm basically pulling my hair out not really understanding what's going on. Any help would be greatly appreciated. Thanks.

A: 

Personally, I haven't found much use for addCloseHandler, but the addClosingHandler is very useful to confirm navigation.

I'm not sure I understand what you mean when you say "swap a panel within your widget". Are you changing the history token? (i.e. History.newItem("page"); or a History widget) Or maybe your manually adding a widget to the DOM? In both cases, however, neither IE nor Firefox should fire the ClosingEvent.

My experience with the ClosingEvent is that it is pretty uniform across browsers, so maybe it would be worth describing the precise differences you observe in more details.

Philippe Beaudoin