Wednesday, June 30, 2010

Re: How to simplify your GwtEvent classes and have fun doing it!

> It is a bit of a nuisance maintaining two java files for each event.

I agree that GWT events involve a lot of boilerplate.

My approach was to write an annotation processor (native Eclipse/javac
support) where you just write a "spec":

@GenEvent
public class CalendarChangeRequestEventSpec {
Date from;
Date till;
}

And that's it. The event/handler/type get generated for you as soon as
you hit save. Change "from" to "foo", hit save, the generated code is
immediately up to date with a "getFoo" method instead of "getFrom",
updated hashCode, updated equals, etc. It's pretty slick.

I just recently pushed the code out to github:

http://github.com/stephenh/gwt-mpv-apt

- Stephen

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment