Overview
- There is a GWT method called:
private void handleError()
- There is a JSNI Javascript function called:
private native void registerErrorHandler()
- The native javascript function calls another function from a third party Javascript library:
foo.attachEvent("EventName", handlerReference);
Functionality
I need to pass the GWT method as a function parameter into the foo.attachEvent()
function, i tried several approaches:
foo.attachEvent("Error", registerErrorHandler);
->
TypeMismatchException
foo.attachEvent("Error", this.@package.foo::registerErrorHandler());
->
TypeMismatchException
var handler = this.@package.foo::registerErrorHandler()();
foo.attachEvent("Error", handler);
-> TypeMismatchException
Plain Javascript
When I write this in plain Javascript, it's working:
function handleError() {
alert("Error");
}
function registerErrorHandler() {
var event = "Error";
var handler = handleError;
foo.attachEvent (event, handler);
}
How can I implement that into GWT? I am having a lot of problems completely understanding the Javascript - Java Objects conversion. I understand the handleError
function reference as a JavaScriptObject
, but I am not able to get it working with that information.