Using javascript variable from GWT Java
I have defined a javascript variable in head section of html file. E.g var开发者_JAVA技巧 yourName = "Nadeem"; Now I want to utilize this variable in my gwt java file/class/method. But it shows an error: Undefined. Please suggest some hints. Best Wishes.
The trick is to use the right "context" where the variable is defined, i.e. $wnd
:
static native String getYourName() /*-{
return $wnd.yourName;
}-*/;
See http://code.google.com/webtoolkit/doc/latest/DevGuideCodingBasicsJSNI.html#writing
精彩评论