Monday, January 30, 2012

GWT and method overriding

I was hoping someone could explain to me why the following isn't working in GWT.  I've been staring at this for a while now and clearly I'm missing something simple.  Hopefully someone can hit me with a clue stick and fill me in on what I'm missing.

We have a custom callback class defined as:
public abstract class MyCallback<T> implements AsyncCallback<T>

which looks at the exception type in onFailure and takes some action based on the class type.  A new type check has been added:
public void onFailure(Throwable t) {
  ...
  if (t instanceof SomeException) {
    handleException((SomeException)t);
  }

where handleException(SomeException) is defined in the custom callback class as:
public void handleException(SomeException ex) {
   // empty
}

When the callback object is actually created and used in an RPC dispatch (we're using gwt-dispatch), the handleException method is defined then:
dispatch.execute(someAction, new MyCallback<someActionResult>() {
   // implementation of a couple abstract methods from MyCallback

  public void handleException(SomeException ex) {
    // do actual work here
  }
});

The issue is that the "do actual work" handleException method is never being called.  Only the base handleException (the empty one in MyCallback) is being called, not the overridden method.  I'm sure I've completely overlooked something simple so any explanation as to why it's not/won't work, or how to get it working would be greatly appreciated.  It seems like something similar works in Java, just curious how to get it working here.

Thank you in advance.


--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/Nfcl2i1Q6GIJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment