com.extjs.gxt.ui.client.data.RpcProxy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gxt Show documentation
Show all versions of gxt Show documentation
Rich Internet Application Framework for GWT
/*
* Sencha GXT 2.3.1a - Sencha for GWT
* Copyright(c) 2007-2013, Sencha, Inc.
* [email protected]
*
* http://www.sencha.com/products/gxt/license/
*/
package com.extjs.gxt.ui.client.data;
import com.google.gwt.user.client.rpc.AsyncCallback;
/**
* DataProxy
implementation that retrieves data using GWT RPC.
*
* @param the data type being returned by the proxy
*/
public abstract class RpcProxy implements DataProxy {
public void load(final DataReader reader, final Object loadConfig,
final AsyncCallback callback) {
load(loadConfig, new AsyncCallback() {
public void onFailure(Throwable caught) {
callback.onFailure(caught);
}
@SuppressWarnings("unchecked")
public void onSuccess(Object result) {
try {
D data = null;
if (reader != null) {
data = reader.read(loadConfig, result);
} else {
data = (D) result;
}
callback.onSuccess(data);
} catch (Exception e) {
callback.onFailure(e);
}
}
});
}
/**
* Subclasses should make RPC call using the load configuration.
*
* @param callback the callback to be used when making the rpc call.
*/
protected abstract void load(Object loadConfig, AsyncCallback callback);
}