title: How to call GWT java function from Javascript?
body: <p>Is it possible to call Java (GWT) methods from Javascript? It is also unclear from documentation. All samples here <a href="http://code.google.com/intl/ru/webtoolkit/doc/latest/DevGuideCodingBasicsJSNI.html">http://code.google.com/intl/ru/webtoolkit/doc/latest/DevGuideCodingBasicsJSNI.html</a> demonstrate calling java functions from JSNI (not JS) functions.</p>
  
  <p><strong>UPDATE 1</strong></p>
  
  <p>Here is a Java code:</p>
  
  <pre><code>public class Test_GoogleWeb_JSNI_02 implements EntryPoint {
  /**
   * This is the entry point method.
   */
  public void onModuleLoad() {
  }
  
  public static void Callee() {
      Window.alert("Callee");
  }
  }
  </code></pre>
  
  <p>Here is caller button samples in html:</p>
  
  <pre><code>&lt;input type='button' value='Call' onclick='Test02()'&gt;
  </code></pre>
  
  <p>And here are some functions I tried and which were not worked:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  
      function Test01() {
          @com.inthemoon.tests.client.Test_GoogleWeb_JSNI_02::Callee()();
      }
  
      function Test02() {
          com.inthemoon.tests.client.Test_GoogleWeb_JSNI_02::Callee()();
      }
  
  
  &lt;/script&gt;
  </code></pre>
  
  <p><strong>UPDATE 2</strong></p>
  
  <p>The following worked.</p>
  
  <p>Java preparation:</p>
  
  <pre><code>public void onModuleLoad() {
      Prepare();
  }
  
  public static native void Prepare() /*-{
      $doc.calleeRunner = @com.inthemoon.tests.client.Test_GoogleWeb_JSNI_02::Callee();
  }-*/;
  
  public static void Callee() {
      Window.alert("Callee");
  }
  </code></pre>
  
  <p>Caller:</p>
  
  <pre><code>function Test03() {
          document.calleeRunner();
  }
  </code></pre>
  
  <p>Is there a better way?</p>