Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firing Order of GWT EventHandlers

Tags:

Is there a known order to the firing of GWT EventHandlers?

ie. If I have a class that extends ListBox and add an EventHandler from the constructor, can I be sure that this Handler will be called before another Handler which is added later on by a surrounding class?

Likewise, if a subclass takes the constructor:

Subclass() {
    super();
    addChangeHandler(new ChangeHandler() {
        // ...
    });
}

But the superclass has the same constructor which adds a ChangeHandler:

Superclass(){
    addChangeHandler(new ChangeHandler() {
        // ...
    });
}

Can we assume the order in which they will be triggered as the superclass's constructor was called and added the Handler before the subclass?

Many thanks, this has been puzzling me.

Chris.

like image 960
Chris J Avatar asked Jul 06 '09 10:07

Chris J


1 Answers

The firing does occur in the order that the handlers are added. This isn't documented in the javadoc as far as I can tell but I dove into the GWT code and the com.google.gwt.event.shared.HandlerManager.HandlerRegistry.fireEvent(GwtEvent, boolean) method eventually gets called when an event gets fired.

There are some cases where all the events are fired in reverse order but this doesn't seem to be tied to the main widgets. If you do a call hierarchy on com.google.gwt.event.shared.HandlerManager.HandlerManager(Object, boolean) you will see who calls the HandlerManager with reverse firing enabled.

like image 85
Carnell Avatar answered Oct 13 '22 01:10

Carnell