Package io.jmix.ui.model
Interface CollectionLoader<E>
- All Superinterfaces:
BaseCollectionLoader
,DataLoader
- All Known Implementing Classes:
CollectionLoaderImpl
Loader of entity collections.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic class
Event sent after successful loading of entities, merging them intoDataContext
and setting to the container.static class
Event sent before loading entities. -
Method Summary
Modifier and TypeMethodDescriptionaddPostLoadListener
(Consumer<CollectionLoader.PostLoadEvent<E>> listener) Adds a listener toCollectionLoader.PostLoadEvent
.addPreLoadListener
(Consumer<CollectionLoader.PreLoadEvent<E>> listener) Adds a listener toCollectionLoader.PreLoadEvent
.ReturnsLoadContext
which is created by the parameters of this loader.Returns the container which accepts loaded entities.Returns the fetch plan used for loading entities.Function<LoadContext<E>,
List<E>> Returns a function which will be used to load data instead of standard implementation.boolean
Returns true if the query for loading data is cacheable.void
setCacheable
(boolean cacheable) Sets the query for loading data cacheable.void
setContainer
(CollectionContainer<E> container) Sets the container which accepts loaded entities.void
setFetchPlan
(FetchPlan fetchPlan) Sets the fetch plan to use for loading entities.void
setFetchPlan
(String fetchPlanName) Sets the name of the fetch plan to use for loading entities.void
setLoadDelegate
(Function<LoadContext<E>, List<E>> delegate) Sets a function which will be used to load data instead of standard implementation.Methods inherited from interface io.jmix.ui.model.BaseCollectionLoader
getFirstResult, getMaxResults, getSort, setFirstResult, setMaxResults, setSort
Methods inherited from interface io.jmix.ui.model.DataLoader
getCondition, getDataContext, getHints, getParameter, getParameters, getQuery, load, removeParameter, setCondition, setDataContext, setHint, setParameter, setParameters, setQuery
-
Method Details
-
getContainer
CollectionContainer<E> getContainer()Returns the container which accepts loaded entities.- Specified by:
getContainer
in interfaceBaseCollectionLoader
- Specified by:
getContainer
in interfaceDataLoader
-
setContainer
Sets the container which accepts loaded entities. -
createLoadContext
LoadContext<E> createLoadContext()ReturnsLoadContext
which is created by the parameters of this loader. TheLoadContext
can be used withDataManager
to load data by the same conditions. -
isCacheable
boolean isCacheable()Returns true if the query for loading data is cacheable. -
setCacheable
void setCacheable(boolean cacheable) Sets the query for loading data cacheable. -
getFetchPlan
FetchPlan getFetchPlan()Returns the fetch plan used for loading entities. -
setFetchPlan
Sets the fetch plan to use for loading entities. -
setFetchPlan
Sets the name of the fetch plan to use for loading entities.- Throws:
IllegalStateException
- if the fetch plan has already been set bysetFetchPlan(FetchPlan)
-
getLoadDelegate
Function<LoadContext<E>,List<E>> getLoadDelegate()Returns a function which will be used to load data instead of standard implementation. -
setLoadDelegate
Sets a function which will be used to load data instead of standard implementation. -
addPreLoadListener
Adds a listener toCollectionLoader.PreLoadEvent
.You can also add an event listener declaratively using a controller method annotated with
Subscribe
:@Subscribe(id = "fooDl", target = Target.DATA_LOADER) private void onFooDlPreLoad(CollectionLoader.PreLoadEvent event) { // handle event here }
- Parameters:
listener
- listener- Returns:
- subscription
-
addPostLoadListener
Adds a listener toCollectionLoader.PostLoadEvent
.You can also add an event listener declaratively using a controller method annotated with
Subscribe
:@Subscribe(id = "fooDl", target = Target.DATA_LOADER) private void onFooDlPostLoad(CollectionLoader.PostLoadEvent event) { // handle event here }
- Parameters:
listener
- listener- Returns:
- subscription
-