Sat, 25 Feb 12

Calling GWT code from javascript

Posted in GWT at 7:50 pm by moore | Permalink

There are lots of snippets out there on the internet telling you how to run GWT code from javascript.  Here’s the canonical one.

I recently did a fair bit of this, calling GWT code from jquery.  Two things jumped out:

  • Make sure your jquery method is run in $(window).load(), not $(document).ready(). If you use the latter, your GWT code will not have executed and exported the javascript method to the window object. More on that.
  • I couldn’t find a list of valid java type signatures (even in the JVM book) for the longest time, but here they are, at long last.

Update, 2/26: I ran into some issues with using $window.load().  What you have to do instead is create a gwtonload function and call it from your gwt loader via jsni.  This ensures that GWT code is fully loaded, which $window.onload() does not.

2 Comments »

  1. Tom Carchrae said,

    April 24, 2012 at 7:05 am

    You might want to check out the GWT exporter project as it helps with some of this pain: http://code.google.com/p/gwt-exporter/

  2. moore said,

    April 24, 2012 at 10:43 am

    Thanks Tom, that project looks very useful!

Leave a Comment

 


© Moore Consulting, 2003-2010 +