title: How to pass a GWT method as a parameter into a Javascript function?
body: <p><strong>Overview</strong></p>
  
  <ul>
  <li>There is a GWT method called: <code>private void handleError()</code></li>
  <li>There is a JSNI Javascript function called: <code>private native void registerErrorHandler()</code></li>
  <li>The native javascript function calls another function from a third party Javascript library: <code>foo.attachEvent("EventName", handlerReference);</code></li>
  </ul>
  
  <p><strong>Functionality</strong></p>
  
  <p>I need to pass the GWT method as a function parameter into the <code>foo.attachEvent()</code> function, i tried several approaches:</p>
  
  <p><code>foo.attachEvent("Error", registerErrorHandler);</code> ->
  TypeMismatchException</p>
  
  <p><code>foo.attachEvent("Error", this.@package.foo::registerErrorHandler());</code> ->
  TypeMismatchException</p>
  
  <pre><code>var handler = this.@package.foo::registerErrorHandler()();
  foo.attachEvent("Error", handler);
  </code></pre>
  
  <p>->
  TypeMismatchException</p>
  
  <p><strong>Plain Javascript</strong></p>
  
  <p>When I write this in plain Javascript, it's working:</p>
  
  <pre><code>function handleError() {
      alert("Error");
  }
  function registerErrorHandler() {
      var event = "Error";
      var handler = handleError;
  
      foo.attachEvent (event, handler);
  }
  </code></pre>
  
  <p>How can I implement that into GWT? I am having a lot of problems completely understanding the Javascript - Java Objects conversion. I understand the <code>handleError</code> function reference as a <code>JavaScriptObject</code>, but I am not able to get it working with that information.</p>