Skip to content Skip to sidebar Skip to footer

How To Pass A Gwt Method As A Parameter Into A Javascript Function?

Overview There is a GWT method called: private void handleError() There is a JSNI Javascript function called: private native void registerErrorHandler() The native javascript func

Solution 1:

you code needs to look like this: (there are only one time braces, therefore the function is not executed...)

var handler = this.@package.foo::registerErrorHandler();
foo.attachEvent("Error", handler);

but what you also want to do is wrap your function in the $entry function so that your uncaught exception handler will work:

var handler = this.@package.foo::registerErrorHandler();
foo.attachEvent("Error", $entry(handler));

What you can always do is build a js function that directly calls your gwt function:

var that = this;
var handler = function(){
    that.@package.foo::registerErrorHandler()();
};
foo.attachEvent("Error", $entry(handler));

Post a Comment for "How To Pass A Gwt Method As A Parameter Into A Javascript Function?"