public class MyEvent extends GwtEvent<MyEvent.MyHandler> {
private static Type<MyHandler> TYPE;
public static Type<LegalCreatedHandler> getType() {
if (TYPE == null) {
TYPE = new Type<MyHandler>(); }
return TYPE; }
@Override public Type<MyHandler> getAssociatedType() {
return (Type) TYPE; }
@Override protected void dispatch(MyEvent.MyHandler handler) {
handler.onMyEvent(this); }
public interface MyHandler extends EventHandler {
void onMyEvent(MyEvent event);
}
}
////fire event from your class
fire(new MyEvent());
////ensure that HandlerManager is not null.
///implement handler and register this handler in class that handle this event
this.addHandler(this, MyEvent.getType());
No comments:
Post a Comment