Class AutoSuggestDataAttributeRegistrar
java.lang.Object
com.foreach.across.modules.entity.autosuggest.AutoSuggestDataAttributeRegistrar
Helper that allows registering simple entity (query) based auto-suggest datasets
and attaching them immediately to the scope of an entity configuration or property.
This will register the dataset in the
AutoSuggestDataEndpoint
(which must be
available) and attach the id of the dataset as attribute on the descriptor or configuration.- Since:
- 3.4.0
- Author:
- Arne Vandamme
-
Nested Class Summary
Modifier and TypeClassDescriptionfinal class
AutoSuggestDataAttributeRegistrar.DataSetRegistrar<T extends com.foreach.across.core.support.ReadableAttributes>
Alias to allow direct control specification after dataset attribute.static class
Holds the configuration for anInitializingAutoSuggestDataSet
based on an entity configuration. -
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The id of the auto-suggest dataset that should be used when building aAutoSuggestFormElement
. -
Method Summary
Modifier and TypeMethodDescription<U extends com.foreach.across.core.support.ReadableAttributes>
AttributeRegistrar<U>control
(@NonNull Consumer<AutoSuggestFormElementConfiguration> controlConsumer) Registers or customizes only theAutoSuggestFormElementConfiguration
which determines the default settings for the auto-suggest control (for example the minimum length before fetching results).<U extends com.foreach.across.core.support.ReadableAttributes>
AutoSuggestDataAttributeRegistrar.DataSetRegistrar<U>Registers the dataset with the given id as auto-suggest datasource.<U extends com.foreach.across.core.support.ReadableAttributes>
AutoSuggestDataAttributeRegistrar.DataSetRegistrar<U>entityQuery
(@NonNull String suggestionsEql) Register a simple dataset that uses an EQL statement to fetch the results.<U extends com.foreach.across.core.support.ReadableAttributes>
AutoSuggestDataAttributeRegistrar.DataSetRegistrar<U>entityQuery
(@NonNull Consumer<AutoSuggestDataAttributeRegistrar.EntityDataSetConfiguration<? super Object>> dataSetConsumer) Register an entity configuration basedInitializingAutoSuggestDataSet
dataset that will be initialized upon first use.
-
Field Details
-
DATASET_ID
The id of the auto-suggest dataset that should be used when building aAutoSuggestFormElement
.
-
-
Method Details
-
dataSetId
public <U extends com.foreach.across.core.support.ReadableAttributes> AutoSuggestDataAttributeRegistrar.DataSetRegistrar<U> dataSetId(@NonNull @NonNull String dataSetId) Registers the dataset with the given id as auto-suggest datasource. This is the equivalent of directly setting theDATASET_ID
attribute.- Parameters:
dataSetId
- id of the dataset- Returns:
- attribute registrar
-
entityQuery
public <U extends com.foreach.across.core.support.ReadableAttributes> AutoSuggestDataAttributeRegistrar.DataSetRegistrar<U> entityQuery(@NonNull @NonNull String suggestionsEql) Register a simple dataset that uses an EQL statement to fetch the results. The entity configuration of the target type wil be used for query execution and result transformation (using the available entity model). The target entity configuration will be derived from the context on which the attribute is being registered (eitherEntityConfiguration
orEntityPropertyDescriptor
. The EQL statement can hold a\{0\} token
where the actual search string will be inserted. The default number of results will be limited to 50.- Parameters:
suggestionsEql
- eql to fetch the suggestions- Returns:
- attribute registrar
- See Also:
-
entityQuery
public <U extends com.foreach.across.core.support.ReadableAttributes> AutoSuggestDataAttributeRegistrar.DataSetRegistrar<U> entityQuery(@NonNull @NonNull Consumer<AutoSuggestDataAttributeRegistrar.EntityDataSetConfiguration<? super Object>> dataSetConsumer) Register an entity configuration basedInitializingAutoSuggestDataSet
dataset that will be initialized upon first use. The default number of results will be limited to 50. If noAutoSuggestDataAttributeRegistrar.EntityDataSetConfiguration.entityType(Class)
is specified manually, it will be derived from the context on which the attribute is being registered.- Parameters:
dataSetConsumer
- to customize the dataset properties- Returns:
- attribute registrar
- See Also:
-
control
public <U extends com.foreach.across.core.support.ReadableAttributes> AttributeRegistrar<U> control(@NonNull @NonNull Consumer<AutoSuggestFormElementConfiguration> controlConsumer) Registers or customizes only theAutoSuggestFormElementConfiguration
which determines the default settings for the auto-suggest control (for example the minimum length before fetching results).- Parameters:
controlConsumer
- consumer to customize the configuration- Returns:
- attribute registrar
-