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
DataProxyandDataReaderto 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.HandlerRegistrationaddBeforeLoadHandler(BeforeLoadEvent.BeforeLoadHandler<C> handler)Adds aBeforeLoadEventhandler.com.google.gwt.event.shared.HandlerRegistrationaddLoaderHandler(LoaderHandler<C,M> handler)Adds aLoadEventhandler.com.google.gwt.event.shared.HandlerRegistrationaddLoadExceptionHandler(LoadExceptionEvent.LoadExceptionHandler<C> handler)Adds aLoadExceptionEventhandler.com.google.gwt.event.shared.HandlerRegistrationaddLoadHandler(LoadHandler<C,M> handler)Adds aLoadEventhandler.CgetLastLoadConfig()Returns the last load config.DataProxy<?,?>getProxy()Returns the loader's data proxy.booleanisReuseLoadConfig()Returns true if the load config is being reused.booleanload()Loads the data using the current configuration.booleanload(C loadConfig)Loads the data using the given load configuration.voidsetReuseLoadConfig(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.HasBeforeLoadHandlersAdds aBeforeLoadEventhandler.- Specified by:
addBeforeLoadHandlerin 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.HasLoaderHandlersAdds aLoadEventhandler.- Specified by:
addLoaderHandlerin 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.HasLoadExceptionHandlersAdds aLoadExceptionEventhandler.- Specified by:
addLoadExceptionHandlerin 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.HasLoadHandlersAdds aLoadEventhandler.- Specified by:
addLoadHandlerin 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 theBeforeLoadEventbefore the request, then theLoadEventafter 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 theBeforeLoadEventbefore the request, then theLoadEventafter 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
-
-