Im trying to read the return value of a Java Method and save it into a JS variable. According to the documentation, this should do the job:
Native Java method that returns the value:
static public double getValue() {
return 21.0;
}
Creation of a reference to call the native Java from handwritten JS:
$wnd.showValue=function() {
val=$entry(@whateverpackage.thisclass::getValue());
alert("Value: "+val);
}
And finally, in plain JS:
showValue();
The output shown in the alert box is this:
Value: function(){try{return hh(c,this,arguments)}catch(b){throw b}}
Im guessing that instead of getting the return value, it gets the function that GWT compiler produces itself and dumps it on the variable. What is wrong in this? Like I said, there is a very similar example in the official documentation, so this should be the way. Thanks in advance.
You have to add an extra pair of brackets after your function reference. The first pair contains the function signature (describing the parameter types). Now you’re not executing the function but instead passing the actual function to
$entry()So change this
to this
Btw I added the var keyword to prevent any potential scope conflicts.