Wednesday, November 23, 2011

GWT Things to Remember

Hi all,

I'm Sam, lead programmer for RPSTag. I'm developing using Google Web Toolkit and Google App Engine. I'm going to be making a few posts now and again about development using those tools, and I thought I'd start here.

Been running into a few issues that have been major stumbling blocks for my work (throughout the whole project, not particularly recently). Thought I'd stick up a couple of quick notes for anyone who had a similar issue in the future...

  1. getWidgetWidth(), getWidgetHeight(), getAbsoluteLeft(), getAbsoluteRight() return 0 - none of these work unless the Widget is actually attached to the RootPanel. I was having a ton of issues implementing a carousel in a way that didn't make assumptions about the content. I had it narrowed down to these method calls not returning anything, but couldn't come up with a solution, so I did an ugly hack. Since then, I figured this out and fixed it, but it was a huge thorn in my side.
  2. TypeError: Cannot call method 'nullMethod' of null (Comes up as a JavaScriptException on the client side)- This issue cropped up with object serialization from my App Engine backend. I was having the hardest time figuring out why it was that this wasn't working... but eventually I figured it out. In my no-argument constructor for the IsSerializable interface, I called the main constructor for the object, and passed in null List objects. In the main constructor, I used methods of those objects. So, it was a dumb null pointer error, and GWT's error message for this provided inadequate information for me to figure this out until I spent a few hours pouring over the stack trace.

That's all for now... anyone else have any helpful GWT tips?

-Sam