Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8212635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T10:49:33+00:00 2026-06-07T10:49:33+00:00

Overview There is a GWT method called: private void handleError() There is a JSNI

  • 0

Overview

  • There is a GWT method called: private void handleError()
  • There is a JSNI Javascript function called: private native void registerErrorHandler()
  • The native javascript function calls another function from a third party Javascript library: foo.attachEvent("EventName", handlerReference);

Functionality

I need to pass the GWT method as a function parameter into the foo.attachEvent() function, i tried several approaches:

foo.attachEvent("Error", registerErrorHandler); ->
TypeMismatchException

foo.attachEvent("Error", this.@package.foo::registerErrorHandler()); ->
TypeMismatchException

var handler = this.@package.foo::registerErrorHandler()();
foo.attachEvent("Error", handler);

->
TypeMismatchException

Plain Javascript

When I write this in plain Javascript, it’s working:

function handleError() {
    alert("Error");
}
function registerErrorHandler() {
    var event = "Error";
    var handler = handleError;

    foo.attachEvent (event, handler);
}

How can I implement that into GWT? I am having a lot of problems completely understanding the Javascript – Java Objects conversion. I understand the handleError function reference as a JavaScriptObject, but I am not able to get it working with that information.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T10:49:34+00:00Added an answer on June 7, 2026 at 10:49 am

    you code needs to look like this: (there are only one time braces, therefore the function is not executed…)

    var handler = this.@package.foo::registerErrorHandler();
    foo.attachEvent("Error", handler);
    

    but what you also want to do is wrap your function in the $entry function so that your uncaught exception handler will work:

    var handler = this.@package.foo::registerErrorHandler();
    foo.attachEvent("Error", $entry(handler));
    

    What you can always do is build a js function that directly calls your gwt function:

    var that = this;
    var handler = function(){
        that.@package.foo::registerErrorHandler()();
    };
    foo.attachEvent("Error", $entry(handler));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In visual studio there is the so called 'test view' that provides an overview
In Google Analytics, if you goto Traffic Sources -> Overview There's a pie chart
Does anyone know if there is an overview of the performance of different cache
I have a document that is an overview document within a folder, there are
I' working on MS CRM 4.0. Is there a possibility to show an overview
Overview Are there explanations for Control.BeginInvoke() to not execute a delegate that it is
Is there an overview of all my code projects on google code? What is
Is there a good overview of tcp data path in Linux (2.6, not 2.4
Is there any good overview of the JFace label provider framework? The JFace snippets
Are there a good overview/comparison of Flash-authoring tools somewhere online? By Flash-authoring tools I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.