Monday, June 17, 2019

Re: JSNI - access inner class attribute from external JS?



On Monday, June 17, 2019 at 5:15:26 AM UTC-5, Jens wrote:
Your setValue() method must be static if you want to call it that way. If it must be an instance method you need to write barInstance.@pkg.Foo.Bar::method (don't forget the dot after instance variable)

-- J.
 
Thanks for your help Jens.  Is there some documentation that explains this syntax to any degree?  All I can find is this and it isn't enough - http://www.gwtproject.org/doc/latest/DevGuideCodingBasicsJSNI.html#calling


I've tried what you describe but when I call it from my external javascript I get an error indicating that the function I'm calling is not defined.  It passes the GWT compiler but at runtime it can't find the function.  I feel like the syntax isn't correct but I'm not seeing it.  Should "Bar" be the instance name of the internal class within the outer class?  I tried that too, same result.

Here is the updated native method:

public native void setValueFromExternal(int newValue) /*-{
Bar.maxInstance.@pkg.Foo.Bar::setValue(I)(newValue);
}-*/; 


The call from the external javascript file is still the same:

function setValue(value){
    this.setValueFromExternal(value);

}

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit/1e0c78d9-65e6-438c-9bbd-5284a088e47f%40googlegroups.com.

No comments:

Post a Comment