Using JSON for GWT

If you’re going to use JSON for a GWT application, truly, you should truly RTFM… JavaScript overlay types are to the rescue. Especially if your data source is on server remote to your module(s). I’d start here Coding Basics – JavaScript Overlay Types. At the bottom of “Coding Basics – JavaScript Overlay Types” are some links to videos, that are worth watching, but you can watch those later.

After reading that article, I’d head on over to Coding Basics – JavaScript Native Interface (JSNI). Coding Basics – JavaScript Native Interface (JSNI) will give you more than enough background on the connection between your JSON/Java communication. In this article, make sure you pay close attention to the section Sharing objects between Java source and JavaScript. This section is extremely helpful. For example, for your JSNI items, don’t use Java’s primitive long.

GWT purposely does not allow for SOP (Same Origin Policy), thus reducing the possibility of cross-site exploits. With that knowledge, next, I’d read Making cross-site requests. This third article will make it clear on how your GWT application can dynamically request and apply JSON data. Again, make sure you trust your data source before using this.

Lastly, as a bit of sanity check, I’d hit Design: Overlay Types. One thing you’ll notice about the JavaScriptObject examples, they don’t use primitive wrappers! This is not a mistake – if you try to use primitive wrappers, you will fail. Note, this last item, “”, was last updated in February of 2010. So, it will have some out of date items, but it will better prepare you.

This entry was posted in GWT. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *