Sunday, March 1, 2009

GWT - Javascript to GWT calls

JavaScipt and GWT interoperation are base on JSNI (JavaScript Native Interface)

Note: A JSNI comment block begins with the exact token /*-{ and ends with the exact token }-*/.

Here is an example of JSNI in GWT

public static native void alert(String msg) /*-{



Tips: When accessing the browser's window and document objects from JSNI, you must reference them as $wnd and $doc, respectively.

JSNI's param-signature follows Java data type declaration

For example myMethod(IFLjava/lang/String;)(); refers to this methoda has 3 parameters of Integer, Float and String

Consider the following which generate a HTML code, register a JS method and provide a call back

Add genHtml() to a Panel. Ie, panel.setHtml(genHtml()); If you onClick to the link, it will call onLinkClicked. This way, you can interact with your GWT application

No comments:

Post a Comment

Sed - Example guide

sed is a very useful stream editor to perform search and replace. Below are some useful tip 1. Usage sed 's/apple/orange/' file...