Friday, May 28, 2010


GWT event template

Just created this, and thought it worth preserving (not sure about lifespan of:

public class ${argType}Event extends GwtEvent<${argType}Event.${argType}EventHandler> {

public interface ${argType}EventHandler extends EventHandler {
void on${argType}(${argType}Event ${argType});

public static final Type<${argType}EventHandler> TYPE = new Type<${argType}EventHandler>();
private final String reason;

public ${argType}Event(String reason) {
this.reason = reason;

protected void dispatch(${argType}EventHandler handler) {

public<${argType}EventHandler> getAssociatedType() {
return TYPE;

public String getReason() {
return reason;

public String toString() {
return "${argType}Event:"+reason+":"+super.toString();


GWT events are key to building a maintainable GUI I think, but it's a pain to cut'n'paste code for it.

Labels: , ,

This page is powered by Blogger. Isn't yours?