Last active
December 18, 2015 00:59
-
-
Save spg/5700772 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ===== USAGE | |
private void fetchevent() { | |
eventService.getEvent(id, new MethodCallbackImpl<Event>() { | |
@Override | |
public String getErrorMessage() { | |
return "Could not fetch event " + id; | |
} | |
@Override | |
public void onSuccess(Event event) { | |
displayEvent(event); | |
} | |
}); | |
} | |
// ===== THE ABSTRACT CLASS | |
package com.sceneverse.shozon.client.util; | |
import org.fusesource.restygwt.client.Method; | |
import org.fusesource.restygwt.client.MethodCallback; | |
import com.google.gwt.user.client.Window; | |
public abstract class MethodCallbackImpl<T> implements MethodCallback<T> { | |
@Override | |
public void onSuccess(Method method, T result) { | |
onSuccess(result); | |
} | |
@Override | |
public void onFailure(Method method, Throwable throwable) { | |
String message = getErrorMessage(); | |
Window.alert(message); | |
} | |
public abstract String getErrorMessage(); | |
public abstract void onSuccess(T result); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment