Problem calling instance method from handwritten javascript

Can anyone help with the wrong one in the code below (based on answers to a similar question asked on SO):

public String javaMethod(String input) { return "it works"; } public native void defineBridgeMethod() /*-{ var that = this; $wnd.jsFunction= $entry(function(msg) { that.@com.myclass.ClassName ::javaMethod(Ljava/lang/String;)(msg) }); }-*/; 

The problem is that Javascript does not find jsFunction: alert (jsFunction) in Javascript code returns 'undefined'.

Thanks.

Edit: Ha, after an hour: it turned out that I just needed to return that.@com... !

0
source share
1 answer

Yes, an hour later: it turned out that I just needed to return that.@com... !

The bridge method should be:

 public native void defineBridgeMethod() /*-{ var that = this; $wnd.jsFunction= $entry(function(msg) { return that.@com.myclass.ClassName ::javaMethod(Ljava/lang/String;)(msg) }); }-*/; 
+2
source

All Articles