In order to accomplish this, you'll first need to create a JSNI method that creates a JavaScript method that in turn makes the call to your Java method. In your GWT application's
Confused yet? It's actually quite simple.
The code snippet below shows an example of this (courtesy of Robert Hanson):
onModuleLoad()
, you would call that JSNI method so that the JavaScript method is defined. From your application host page you would then call the created JavaScript method.
Confused yet? It's actually quite simple.
The code snippet below shows an example of this (courtesy of Robert Hanson):
private native void initPlaylistJS (PlaylistTable pl) /*-{ $wnd.addClipToPlaylist = function (clipId, clipTitle) { pl.@com.foo.bar.client.PlaylistTable::addClip(Ljava/lang/String;Ljava/lang/String;)(clipId, clipTitle); }; }-*/;In this example, you would need to make a call to
initPlaylistJS(pl)
in your GWT module's onModuleLoad()
. Once your GWT application loads, the JavaScript method is defined and is callable from outside of the GWT application.