Class Loader<C,M>
- java.lang.Object
-
- com.sencha.gxt.data.shared.loader.Loader<C,M>
-
- Type Parameters:
C
- the type of the data used to configureM
- 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
andDataReader
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.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description com.google.gwt.event.shared.HandlerRegistration
addBeforeLoadHandler(BeforeLoadEvent.BeforeLoadHandler<C> handler)
Adds aBeforeLoadEvent
handler.com.google.gwt.event.shared.HandlerRegistration
addLoaderHandler(LoaderHandler<C,M> handler)
Adds aLoadEvent
handler.com.google.gwt.event.shared.HandlerRegistration
addLoadExceptionHandler(LoadExceptionEvent.LoadExceptionHandler<C> handler)
Adds aLoadExceptionEvent
handler.com.google.gwt.event.shared.HandlerRegistration
addLoadHandler(LoadHandler<C,M> handler)
Adds aLoadEvent
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).
-
-
-
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.- Type Parameters:
T
- the type of data being proxied- Parameters:
proxy
- the data proxyreader
- the data reader
-
-
Method Detail
-
addBeforeLoadHandler
public com.google.gwt.event.shared.HandlerRegistration addBeforeLoadHandler(BeforeLoadEvent.BeforeLoadHandler<C> handler)
Description copied from interface:BeforeLoadEvent.HasBeforeLoadHandlers
Adds aBeforeLoadEvent
handler.- Specified by:
addBeforeLoadHandler
in interfaceBeforeLoadEvent.HasBeforeLoadHandlers<C>
- Parameters:
handler
- the handler- Returns:
- the registration for the event
-
addLoaderHandler
public com.google.gwt.event.shared.HandlerRegistration addLoaderHandler(LoaderHandler<C,M> handler)
Description copied from interface:LoaderHandler.HasLoaderHandlers
Adds aLoadEvent
handler.- Specified by:
addLoaderHandler
in interfaceLoaderHandler.HasLoaderHandlers<C,M>
- Parameters:
handler
- the handler- Returns:
- the registration for the event
-
addLoadExceptionHandler
public com.google.gwt.event.shared.HandlerRegistration addLoadExceptionHandler(LoadExceptionEvent.LoadExceptionHandler<C> handler)
Description copied from interface:LoadExceptionEvent.HasLoadExceptionHandlers
Adds aLoadExceptionEvent
handler.- Specified by:
addLoadExceptionHandler
in interfaceLoadExceptionEvent.HasLoadExceptionHandlers<C>
- Parameters:
handler
- the handler- Returns:
- the registration for the event
-
addLoadHandler
public com.google.gwt.event.shared.HandlerRegistration addLoadHandler(LoadHandler<C,M> handler)
Description copied from interface:LoadHandler.HasLoadHandlers
Adds aLoadEvent
handler.- Specified by:
addLoadHandler
in interfaceLoadHandler.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 theBeforeLoadEvent
before the request, then theLoadEvent
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 theBeforeLoadEvent
before the request, then theLoadEvent
after the load operation. The current load configuration object can be retrieved usinggetLastLoadConfig()
.- 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
-
-