2
votes

I have gwt-project that is comunication to database.

Application design mvp pattern and view has a input form, a grid and many buttons.

According to gwt tutorial, each event has a event class, a event handler class and initialize event handler class in presenter.

So, Do I make event and event handler class if the number of events are uncountable?

[Example package] :

src/com/example/event/${A Lot Of Event}

src/com/example/event/${A Lot Of Event Handler}

src/com/example/presenter/${A Presenter}

src/com/example/view/${A View}

1

1 Answers

2
votes

I like to put the event handler (and optionally the has handlers interface, if you make one) as inner classes (okay, interfaces) of the event itself. Usually looks something like this:

public class MyAppEvent extends GwtEvent<MyAppEventHandler> {

    //... event guts, dispatch, getAssociatedType, etc


    public interface MyAppEventHandler extends EventHandler {
        void onMyAppEventHappened(MyAppEvent event);
    }


    // and optionally, if you only register handlers through add methods
    public interface HasMyAppEventHandlers {
        void addMyAppEventHandler(MyAppEventHandler handler);
    }
}