Using the JavaScript Native Interface of GWT I can perform the following:
public native static String getNativeVariableFoo() /*-{
return $wnd.foo;
}-*/;
Which will return the contents of a JavaScript variable called foo.
How can I expand upon this to accept the variable name as a parameter? ie:
public native static String getNativeVariable(String foo) /*-{
/* Somehow meaningfully concat '$wnd.' with value of foo */
}-*/;
Simply using the variable name inside the native code like one would to call:
eval(foo)
results in the JavaScript hunting for a declaration of a variable named foo and not one named with the value of foo.
Thanks very much!