Reputation: 1423
I have defined a javascript variable in head section of html file. E.g var 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.
Upvotes: 1
Views: 1870
Reputation: 64541
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
Upvotes: 7