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

Tomcat - removing server info

Below are the steps to remove Tomcat Server Information 1. Make sure Tomcat is not running 2. Navigate to "Tomcat Installation"...