I keep having trouble setting up a GWT event handler which is parameterized. All of the magic needs to happen in the GwtEvent class itself.
public class CustomClickEvent<T> extends GwtEvent<HasClickHandler<T>> {
private static Type<HasClickHandler<?>> TYPE = new Type<HasClickHandler<?>>();
private LazyCellClickEvent() {}
@Override
protected void dispatch(CustomClickEventHandler<T> clickEvent) {
clickEvent.onClick(this);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public Type<HasClickHandler<T>> getAssociatedType() {
return (Type)TYPE;
}
public static final Type<HasClickHandler<?> getType() {
return TYPE;
}
public static void fire(HasCustomEventHandler<T> handler) {
CustomClickEvent<T> event = new CustomClickEvent<T>();
handler.fireEvent(event);
}
}
No comments:
Post a Comment