Content
o From the code above, we are getting data back as an array of
JSON data.
o So we use the asArrayOfStockData() method
o We fix this method to handle JSON data like this:
JSON data.
o So we use the asArrayOfStockData() method
o We fix this method to handle JSON data like this:
/** * Convert the string of JSON into JavaScript object. */ private final native JsArrayasArrayOfStockData(String json) /*-{ return eval(json); }-*/;
o Replace the eclipse code with the above code for asArrayOfStockData()
o It is using JavaScript Native Interface (JSNI). See: http://www.gwtproject.org/doc/latest/DevGuideCodingBasicsJSNI.html
for moe details
o JSNI integrate javascript directly into Java source code
o /*-{return eval(json);}-*/;
o It calls the eval() javascript method on the browser side.
o That is, it evaluates the JSON data