Skip to content

Instantly share code, notes, and snippets.

@spg
Last active December 18, 2015 01:48
Show Gist options
  • Save spg/5706518 to your computer and use it in GitHub Desktop.
Save spg/5706518 to your computer and use it in GitHub Desktop.
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 errorFromServer = method.getResponse().getText();
showErrorMessage(errorFromServer);
}
protected void showErrorMessage(String serverError) {
Window.alert(serverError);
}
protected abstract void onSuccess(T result);
}
@spg
Copy link
Author

spg commented Jun 4, 2013

This way, the client

  • can (but is not required to) override onFailure
  • can (but is not required to) override showServerError
  • must implement onSuccess(T result)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment