Friday, June 7, 2013

Re: javascript call to java method doesn´t work in developing mode - but when code is compiled (GWT 2.51)



On Thursday, June 6, 2013 7:50:09 PM UTC+2, Olaf Raether wrote:
If have a Class that looks similar like this:

public class MyClass extends Widget {
public
MyClass() { declareMethod(this); } //Method which declares non-static method in javascript public native void declareMethod(MyClass this) /*-{ var _this = this; $wnd.doSomething = function(someString) { _this.@com.example.MyClass::doSomething(Ljava/lang/String;)(someString); } }-*/; }

Calling something 'this' is a really bad idea. 'this' is a keyword, and I'm surprised this even compiles (though maybe it's allowed in Java, I haven't checked). That said, in this case, both the argument and 'this' should be the same value so it shouldn't be a problem.

This code is missing a call to $entry() though:

        $wnd.doSomething = $entry(function(someString) {              _this.@com.example.MyClass::doSomething(Ljava/lang/String;)(someString);
        });

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment