Writing Native JavaScript Methods
JSNI methods are declared
native
and contain JavaScript
code in a specially formatted comment block between the end of the
parameter list and the trailing semicolon. A JSNI comment block begins
with the exact token
/*-{
and ends with the exact
token
}-*/
. JSNI methods are be called just like any
normal Java method. They can be static or instance methods.
Example
public static native void alert(String msg) /*-{
$wnd.alert(msg);
}-*/;
Tip
In
hosted mode, you can set a
breakpoint on the declaration line of the method, allowing you to
see the arguments to that method invocation.