{"id":799,"date":"2012-02-25T19:50:18","date_gmt":"2012-02-26T01:50:18","guid":{"rendered":"http:\/\/www.mooreds.com\/wordpress\/?p=799"},"modified":"2012-02-26T18:27:31","modified_gmt":"2012-02-27T00:27:31","slug":"calling-gwt-code-from-javascript","status":"publish","type":"post","link":"https:\/\/www.mooreds.com\/wordpress\/archives\/799","title":{"rendered":"Calling GWT code from javascript"},"content":{"rendered":"<p>There are lots of snippets out there on the internet telling you how to run GWT code from javascript.\u00a0 Here&#8217;s the <a href=\"http:\/\/code.google.com\/webtoolkit\/doc\/latest\/DevGuideCodingBasicsJSNI.html#calling\">canonical one<\/a>.<\/p>\n<p>I recently did a fair bit of this, calling GWT code from jquery.\u00a0 Two things jumped out:<\/p>\n<ul>\n<li>Make sure your jquery method is run in <code>$(window).load()<\/code>, not <code>$(document).ready()<\/code>. If you use the latter, your GWT code will not have executed and exported the javascript method to the window object. <a href=\"http:\/\/4loc.wordpress.com\/2009\/04\/28\/documentready-vs-windowload\/\">More on that<\/a>.<\/li>\n<li>I couldn&#8217;t find a list of valid java type signatures (even in the <a href=\"http:\/\/java.sun.com\/docs\/books\/jvms\/second_edition\/ClassFileFormat-Java5.pdf\">JVM book<\/a>) for the longest time, but <a href=\"http:\/\/docs.oracle.com\/javase\/1.5.0\/docs\/guide\/jni\/spec\/types.html#wp276\">here they are, at long last<\/a>.<\/li>\n<\/ul>\n<p><strong>Update, 2\/26: I ran into some issues with using $window.load().\u00a0 What you have to do instead is create a gwtonload function and call it from your gwt loader via jsni.\u00a0 This ensures that GWT code is fully loaded, which $window.onload() does not.<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>There are lots of snippets out there on the internet telling you how to run GWT code from javascript.\u00a0 Here&#8217;s the canonical one. I recently did a fair bit of [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[],"class_list":["post-799","post","type-post","status-publish","format-standard","hentry","category-gwt"],"_links":{"self":[{"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/posts\/799","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/comments?post=799"}],"version-history":[{"count":3,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/posts\/799\/revisions"}],"predecessor-version":[{"id":801,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/posts\/799\/revisions\/801"}],"wp:attachment":[{"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/media?parent=799"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/categories?post=799"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/tags?post=799"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}