com.extjs.gxt.ui.client.data
Class BaseLoader<D>

java.lang.Object
  extended by com.extjs.gxt.ui.client.event.BaseObservable
      extended by com.extjs.gxt.ui.client.data.BaseLoader<D>
Type Parameters:
D - the data type being returned by this loader
All Implemented Interfaces:
Loader<D>, Observable
Direct Known Subclasses:
BaseListLoader, BaseTreeLoader

public class BaseLoader<D>
extends BaseObservable
implements Loader<D>

Abstract base loader implementation.


Field Summary
protected  java.lang.Object lastConfig
           
protected  DataProxy<D> proxy
           
protected  DataReader<D> reader
           
protected  boolean reuseConfig
           
 
Fields inherited from interface com.extjs.gxt.ui.client.data.Loader
BeforeLoad, Load, LoadException
 
Constructor Summary
BaseLoader(DataProxy<D> proxy)
          Creates a new base loader instance.
BaseLoader(DataProxy<D> proxy, DataReader<D> reader)
          Creates a new loader with the given proxy and reader.
BaseLoader(DataReader<D> reader)
          Creates a new base loader instance.
 
Method Summary
 void addLoadListener(LoadListener listener)
          Adds a load listener.
 java.lang.Object getLastConfig()
          Returns the last config.
 DataProxy<? extends D> getProxy()
          Returns the loader's data proxy.
 boolean isReuseLoadConfig()
          Returns true if the load config is being reused.
 boolean load()
          Loads the data using the current configuration.
 boolean load(java.lang.Object loadConfig)
          Loads the data using the given load configuration.
protected  void loadData(java.lang.Object config)
           
protected  void loadData(java.lang.Object config, com.google.gwt.user.client.rpc.AsyncCallback<D> callback)
          Called when a proxy is not being used.
protected  java.lang.Object newLoadConfig()
          Template method to allow custom BaseLoader subclasses to provide their own implementation of LoadConfig
protected  void onLoadFailure(java.lang.Object loadConfig, java.lang.Throwable t)
          Called when a load operation fails.
protected  void onLoadSuccess(java.lang.Object loadConfig, D data)
          Called when the remote data has been received.
protected  java.lang.Object prepareLoadConfig(java.lang.Object config)
          Template method to allow custom subclasses to prepare the load config prior to loading data
 void removeLoadListener(LoadListener listener)
          Removes a load listener.
 void setReuseLoadConfig(boolean reuseLoadConfig)
          Sets whether the same load config instance should be used for load operations.
 
Methods inherited from class com.extjs.gxt.ui.client.event.BaseObservable
addListener, callListener, fireEvent, fireEvent, getFiresEvents, getListeners, hasActiveEvent, hasListeners, hasListeners, removeAllListeners, removeListener, setFiresEvents
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.extjs.gxt.ui.client.event.Observable
addListener, fireEvent, getListeners, hasListeners, hasListeners, removeAllListeners, removeListener
 

Field Detail

proxy

protected DataProxy<D> proxy

reader

protected DataReader<D> reader

lastConfig

protected java.lang.Object lastConfig

reuseConfig

protected boolean reuseConfig
Constructor Detail

BaseLoader

public BaseLoader(DataProxy<D> proxy)
Creates a new base loader instance.

Parameters:
proxy - the data proxy

BaseLoader

public BaseLoader(DataProxy<D> proxy,
                  DataReader<D> reader)
Creates a new loader with the given proxy and reader.

Parameters:
proxy - the data proxy
reader - an optional data reader, if null, null will be passed to proxy.load(Reader, LoadConfig, DataCallback)

BaseLoader

public BaseLoader(DataReader<D> reader)
Creates a new base loader instance.

Parameters:
reader - the reader
Method Detail

addLoadListener

public void addLoadListener(LoadListener listener)
Description copied from interface: Loader
Adds a load listener.

Specified by:
addLoadListener in interface Loader<D>
Parameters:
listener - the listener to add

getLastConfig

public java.lang.Object getLastConfig()
Returns the last config.

Returns:
the last config

getProxy

public DataProxy<? extends D> getProxy()
Returns the loader's data proxy.

Returns:
the data proxy

isReuseLoadConfig

public boolean isReuseLoadConfig()
Returns true if the load config is being reused.

Returns:
the reuse load config state

load

public boolean load()
Description copied from interface: Loader
Loads the data using the current configuration.

Specified by:
load in interface Loader<D>
Returns:
true if the load was requested

load

public boolean load(java.lang.Object loadConfig)
Description copied from interface: Loader
Loads the data using the given load configuration.

Specified by:
load in interface Loader<D>
Parameters:
loadConfig - the load config
Returns:
true if the load was requested

removeLoadListener

public void removeLoadListener(LoadListener listener)
Description copied from interface: Loader
Removes a load listener.

Specified by:
removeLoadListener in interface Loader<D>
Parameters:
listener - the listener to remove

setReuseLoadConfig

public void setReuseLoadConfig(boolean reuseLoadConfig)
Sets whether the same load config instance should be used for load operations.

Parameters:
reuseLoadConfig - true to reuse

loadData

protected void loadData(java.lang.Object config)

loadData

protected void loadData(java.lang.Object config,
                        com.google.gwt.user.client.rpc.AsyncCallback<D> callback)
Called when a proxy is not being used.

Parameters:
config - the load config
callback - the callback

newLoadConfig

protected java.lang.Object newLoadConfig()
Template method to allow custom BaseLoader subclasses to provide their own implementation of LoadConfig


onLoadFailure

protected void onLoadFailure(java.lang.Object loadConfig,
                             java.lang.Throwable t)
Called when a load operation fails.

Parameters:
loadConfig - the load config
t - the exception

onLoadSuccess

protected void onLoadSuccess(java.lang.Object loadConfig,
                             D data)
Called when the remote data has been received.

Parameters:
loadConfig - the load config
data - data

prepareLoadConfig

protected java.lang.Object prepareLoadConfig(java.lang.Object config)
Template method to allow custom subclasses to prepare the load config prior to loading data