com.sencha.gxt.data.shared.loader
Class Loader<C,M>

java.lang.Object
  extended by com.sencha.gxt.data.shared.loader.Loader<C,M>
Type Parameters:
C - the type of the data used to configure
M - the type of data being returned by the loader
All Implemented Interfaces:
BeforeLoadEvent.HasBeforeLoadHandlers<C>, LoaderHandler.HasLoaderHandlers<C,M>, LoadExceptionEvent.HasLoadExceptionHandlers<C>, LoadHandler.HasLoadHandlers<C,M>
Direct Known Subclasses:
ListLoader, TreeLoader

public class Loader<C,M>
extends Object
implements LoaderHandler.HasLoaderHandlers<C,M>

Abstract base class for objects that can load remote data.

The optional input object passed with the load request is logically called a "load config" with the object returned by the loader called the "load result".

Typically, loaders work with DataProxy and DataReader to help perform the load operations. The DataProxy is responsible for obtaining the remote data. The DataReader is responsible for "processing" the remote data and converting the data to the expected format.

Events:
BeforeLoadEvent
LoadEvent
LoadExceptionEvent


Constructor Summary
Loader(DataProxy<C,M> proxy)
          Creates a new base loader instance.
Loader(DataProxy<C,T> proxy, DataReader<M,T> reader)
          Creates a new loader with the given proxy and reader.
 
Method Summary
 HandlerRegistration addBeforeLoadHandler(BeforeLoadEvent.BeforeLoadHandler<C> handler)
          Adds a BeforeLoadEvent handler.
 HandlerRegistration addLoaderHandler(LoaderHandler<C,M> handler)
          Adds a LoadEvent handler.
 HandlerRegistration addLoadExceptionHandler(LoadExceptionEvent.LoadExceptionHandler<C> handler)
          Adds a LoadExceptionEvent handler.
 HandlerRegistration addLoadHandler(LoadHandler<C,M> handler)
          Adds a LoadEvent handler.
 C getLastLoadConfig()
          Returns the last load config.
 DataProxy<?,?> 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(C loadConfig)
          Loads the data using the given load configuration.
 void setReuseLoadConfig(boolean reuseLoadConfig)
          Sets whether the same load config instance should be used for load operations (defaults to false).
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Loader

public Loader(DataProxy<C,M> proxy)
Creates a new base loader instance. Since a data reader is not used, the data returned by the data proxy will not be read and converted by a reader.

Parameters:
proxy - the data proxy

Loader

public Loader(DataProxy<C,T> proxy,
              DataReader<M,T> reader)
Creates a new loader with the given proxy and reader.

Parameters:
proxy - the data proxy
reader - the data reader
Method Detail

addBeforeLoadHandler

public HandlerRegistration addBeforeLoadHandler(BeforeLoadEvent.BeforeLoadHandler<C> handler)
Description copied from interface: BeforeLoadEvent.HasBeforeLoadHandlers
Adds a BeforeLoadEvent handler.

Specified by:
addBeforeLoadHandler in interface BeforeLoadEvent.HasBeforeLoadHandlers<C>
Parameters:
handler - the handler
Returns:
the registration for the event

addLoaderHandler

public HandlerRegistration addLoaderHandler(LoaderHandler<C,M> handler)
Description copied from interface: LoaderHandler.HasLoaderHandlers
Adds a LoadEvent handler.

Specified by:
addLoaderHandler in interface LoaderHandler.HasLoaderHandlers<C,M>
Parameters:
handler - the handler
Returns:
the registration for the event

addLoadExceptionHandler

public HandlerRegistration addLoadExceptionHandler(LoadExceptionEvent.LoadExceptionHandler<C> handler)
Description copied from interface: LoadExceptionEvent.HasLoadExceptionHandlers
Adds a LoadExceptionEvent handler.

Specified by:
addLoadExceptionHandler in interface LoadExceptionEvent.HasLoadExceptionHandlers<C>
Parameters:
handler - the handler
Returns:
the registration for the event

addLoadHandler

public HandlerRegistration addLoadHandler(LoadHandler<C,M> handler)
Description copied from interface: LoadHandler.HasLoadHandlers
Adds a LoadEvent handler.

Specified by:
addLoadHandler in interface LoadHandler.HasLoadHandlers<C,M>
Parameters:
handler - the handler
Returns:
the registration for the event

getLastLoadConfig

public C getLastLoadConfig()
Returns the last load config.

Returns:
the last load config

getProxy

public DataProxy<?,?> 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()
Loads the data using the current configuration. Fires the BeforeLoadEvent before the request, then the LoadEvent after the load operation.

Returns:
true if the load was requested, false if cancelled

load

public boolean load(C loadConfig)
Loads the data using the given load configuration. Fires the BeforeLoadEvent before the request, then the LoadEvent after the load operation. The current load configuration object can be retrieved using getLastLoadConfig().

Parameters:
loadConfig - the load config
Returns:
true if the load was requested, false if cancelled

setReuseLoadConfig

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

Parameters:
reuseLoadConfig - true to reuse


Copyright © 2012. All Rights Reserved.