How can I call one of my GWT Java methods from my application host page?

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 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) {;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.
Google apps
Main menu
Search Help Center