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