From the course: Learning GWT

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Overlay types and JSNI

Overlay types and JSNI

From the course: Learning GWT

Start my 1-month free trial

Overlay types and JSNI

- [Man] In the previous lesson, we learned how we could use a web service, responding with a JavaScript object annotation object or JSON, to retrieve data. What we did not discuss, is how our Java code will interact and manipulate data, wrapped in JavaScript objects. GWT 1.5 introduced the ability to make JavaScript objects look like Java objects when coding. A technique called JavaScript Overlay types. The best way to describe Overlay types is to show you. Let's go back to the browser and take a look at that object, that's returned from fixer.io In this object, it appears to have two strings. A base and a date and another JSON object containing a set of foreign exchange rates. In order to work with this object, as if it were a regular Java object, we need to create an overlay type for it. So, let's go back to the client package and create a class called FXRates and use the superclass, JavaScriptObject. The JavaScriptObject superclass is really just a market type for GWT to denote…

Contents