Interface LookupField<F extends LookupField<F>>
- All Superinterfaces:
Comparable<F>
,Component<F>
,Copyable<F>
,Dependent<F>
,Field<F>
,Filterable<F>
,FormComponent<F>
,Serializable
,Trackable<F>
- All Known Implementing Classes:
DefaultLookupField
FieldTypes.LOOKUP
field. A lookup field is useful when the
user needs to be able to choose between a number of externally sourced options.- Author:
- Nick Crum (ncrum)
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final class
static final class
static final class
This enum represents the way in which the lookup selections are persisted within the form state.static final class
Nested classes/interfaces inherited from interface com.broadleafcommerce.metadata.dsl.core.extension.Dependent
Dependent.DependentFieldsList
-
Method Summary
Modifier and TypeMethodDescriptiondefault F
Configure the catalog selector to be displayed next to the lookup field in order to hydrate the context with the necessary catalog id parameters for lookup requests.default F
Configures the lookup as creatable.default F
creatable
(boolean isCreatable) Configures whether the lookup is creatable.default Optional<LookupFieldModal<?>>
Finds the metadata for theLookupField.ViewTypes.LOOKUP_MODAL
configured for this lookup.default Optional<PageableEndpoint<?>>
default Endpoint<?>
default PageableEndpoint<?>
default F
hydrateEndpoint
(Endpoint<?> endpoint) Configures the hydration endpoint for the lookup.default F
hydrateEndpoint
(UnaryOperator<Endpoint<?>> fn) Configures the hydration endpoint for the lookup.default F
hydrateScope
(String scope) ConfigureshydrateEndpoint(UnaryOperator)
url.default F
hydrateUrl
(String url) ConfigureshydrateEndpoint(UnaryOperator)
url.default F
hydrateUrl
(String url, String scope) ConfigureshydrateEndpoint(UnaryOperator)
url and scope.default boolean
default F
Sets the name of the label key.default F
loadingMessage
(String loadingMessageKey) Configure the message to be displayed while the lookup is loading it's options.default F
modalComponent
(String modalComponent) Sets the name of the React component that will be used for rendering the modal search.default F
modalSearch
(UnaryOperator<LookupFieldModal<?>> fn) Configure this lookup with a modal for more advanced searching.default F
modalToggleLabel
(String modalLabelKey) Configures the label for the modal search toggle.default F
multi()
Configures this lookup to support multi-selection.default F
multi
(boolean isMulti) Configures whether or not the lookup supports multi-selection.default F
noOptionsMessage
(String noOptionsMessageKey) Configure the message to be displayed when the lookup finds no options.default F
Disables modal support and remove the Advanced button from the lookup field.default F
notMulti()
Configures this lookup to not support multi-selection.default F
Configures the lookup to not be searchable.default F
Configures the lookup with theLookupField.SelectionTypes.OPTION
selection type.default F
readEndpoint
(PageableEndpoint<?> endpoint) Configure the read endpoint for the lookup.default F
Configure the read endpoint for the lookup.default F
ConfiguresreadEndpoint(UnaryOperator)
scope.default F
ConfiguresreadEndpoint(UnaryOperator)
url.default F
ConfiguresreadEndpoint(UnaryOperator)
url with scopedefault F
Remove the catalog selector from the lookup field.default F
Remove any existing transformations added bytransformSelection(com.broadleafcommerce.metadata.dsl.core.Mapping<?>...)
.default F
default F
Configures the lookup to be searchable.default F
searchable
(boolean isSearchable) Configures the lookup to be searchable or notdefault F
Configures the lookup to be searchable and configures the endpoint to map over the default `q` and `cq` parameters.default F
selectComponent
(String selectComponentName) Sets the name of the React component that will be used for rendering the select input.default F
selectionType
(String selectionType) Sets theLookupField.Attributes.SELECTION_TYPE
for this lookup.default F
default F
showModalSearchUnderLookup
(boolean showModalUnderLookup) default F
transformSelection
(Mapping<?>... mappings) Configure a set ofMapping
to transform the option the user selects before the form state is updated.default F
transformSelection
(UnaryOperator<List<Mapping<?>>> fn) Configure a set ofMapping
to transform the option the user selects before the form state is updated.default F
transformSelection
(List<Mapping<?>> mappings) Configure a set ofMapping
to transform the option the user selects before the form state is updated.default F
Sets the name of the value key.default F
Configures the lookup with theLookupField.SelectionTypes.VALUE
selection type.Methods inherited from interface java.lang.Comparable
compareTo
Methods inherited from interface com.broadleafcommerce.metadata.dsl.core.Component
addAction, addAction, addComponent, addEndpoint, addEndpoint, apply, attribute, augmentationKey, classifier, clearConditionals, clearEndpoints, conditional, conditionals, description, description, findAction, findAction, findActions, findAttribute, findAttribute, findComponent, findComponent, findComponents, findEndpoint, findEndpoint, findEndpoint, findEndpoints, get, get, getAction, getAction, getActions, getActionsList, getAttribute, getAttribute, getAttributes, getAugmentationKey, getClassifier, getComponent, getComponent, getComponents, getComponentsList, getConditionals, getDescription, getEndpoint, getEndpoint, getEndpoints, getEndpointsList, getId, getLabel, getOrder, getScope, getType, hasAction, hasAttribute, hasComponent, hasEndpoint, id, isAugmentable, isTranslatable, label, label, notTranslatable, order, removeAction, removeAttribute, removeComponent, removeEndpoint, scope, self, setActions, setAttributes, setAugmentationKey, setClassifier, setComponents, setConditionals, setDescription, setEndpoints, setId, setLabel, setOrder, setScope, setTranslatable, setType, translatable, translatable, type
Methods inherited from interface com.broadleafcommerce.metadata.dsl.core.extension.Dependent
clearDependentFields, dependentField, dependentFields, parentIdField
Methods inherited from interface com.broadleafcommerce.metadata.dsl.core.Field
clearReadOnlyConditionals, decorated, decorated, defaultValue, getDefaultValue, getName, getPlaceholder, getReadOnlyConditionals, getRequiredMessage, getValidationSchema, isReadOnly, isRequired, isShowInQueryBuilder, isTargetCollection, name, notReadOnly, notRequired, placeholder, placeholder, readOnly, readOnly, readOnlyConditional, readOnlyConditionals, required, required, required, required, requiredMessage, requiredMessage, setDefaultValue, setName, setPlaceholder, setReadOnly, setReadOnlyConditionals, setRequired, setRequiredMessage, setShowInQueryBuilder, setValidationSchema, targetIsCollection, targetIsNotCollection, validationMethod, validationSchema, validationSchema
Methods inherited from interface com.broadleafcommerce.metadata.dsl.core.extension.Filterable
implicitFilter, implicitFilters, implicitFilters
Methods inherited from interface com.broadleafcommerce.metadata.dsl.core.FormComponent
getHelpText, getHint, getTooltip, helpText, helpText, helpText, hidden, hidden, hint, hint, isHidden, notHidden, setHelpText, setHidden, setHint, setTooltip, tooltip, tooltip
Methods inherited from interface com.broadleafcommerce.metadata.dsl.core.extension.Trackable
applicationTrackable, applicationTrackable, auditable, auditable, catalogTrackable, notAuditable, notCatalogTrackable, notProfileTrackable, notSandboxTrackable, notSearchGroupTrackable, profileTrackable, sandboxTrackable, searchGroupTrackable
-
Method Details
-
readEndpoint
Configure the read endpoint for the lookup. This endpoint tells the lookup where it can go to retrieve the options the user chooses from. This endpoint is aPageableEndpoint
and supports different paging strategies.- Parameters:
endpoint
- the endpoint- Returns:
- this
-
readEndpoint
Configure the read endpoint for the lookup. This endpoint tells the lookup where it can go to retrieve the options the user chooses from. This endpoint is aPageableEndpoint
and supports different paging strategies.- Parameters:
fn
- function to configure the endpoint- Returns:
- this
-
readUrl
ConfiguresreadEndpoint(UnaryOperator)
url.- Returns:
- this
-
readScope
ConfiguresreadEndpoint(UnaryOperator)
scope.- Returns:
- this
-
readUrl
ConfiguresreadEndpoint(UnaryOperator)
url with scope- Returns:
- this
-
getReadEndpoint
- Returns:
- the read endpoint
-
findReadEndpoint
- Returns:
- an optional with read endpoint, or empty
-
hydrateEndpoint
Configures the hydration endpoint for the lookup. This endpoint tells the lookup where to can go to retrieve the hydrated option for the current value. This endpoint is used when the component mounts to hydrate the option associated with the stored value.This is only necessary when only the option value is being stored in the property as when configured with a
valueSelection()
. This may be necessary in certainoptionSelection()
situations when the option being stored is heavily transformed bytransformSelection(Mapping[])
.- Parameters:
endpoint
- the hydrate endpoint- Returns:
- this
-
hydrateEndpoint
Configures the hydration endpoint for the lookup. This endpoint tells the lookup where to can go to retrieve the hydrated option for the current value. This endpoint is used when the component mounts to hydrate the option associated with the stored value.This is only necessary when only the option value is being stored in the property as when configured with a
valueSelection()
. This may be necessary in certainoptionSelection()
situations when the option being stored is heavily transformed bytransformSelection(Mapping[])
.- Parameters:
fn
- a function to configure the hydrate endpoint- Returns:
- this
-
hydrateUrl
ConfigureshydrateEndpoint(UnaryOperator)
url.- Returns:
- this
-
hydrateScope
ConfigureshydrateEndpoint(UnaryOperator)
url.- Returns:
- this
-
hydrateUrl
ConfigureshydrateEndpoint(UnaryOperator)
url and scope.- Returns:
- this
-
getHydrateEndpoint
- Returns:
- the hydrate endpoint
-
findHydrateEndpoint
- Returns:
- an optional with hydrate endpoint, or empty
-
creatable
Configures the lookup as creatable.- Returns:
- this
-
creatable
Configures whether the lookup is creatable.- Returns:
- this
-
searchable
Configures the lookup to be searchable or not- Parameters:
isSearchable
- whether or not searchable- Returns:
- this
-
searchable
Configures the lookup to be searchable. This allows the user to type text into the select in order to filter the results. If using an API with the standard text query parameters, then usesearchableDefaults()
.- Returns:
- this
-
showModalSearchUnderLookup
-
showModalSearchUnderLookup
-
isSearchable
default boolean isSearchable()- Returns:
- whether or not this lookup is configured as searchable
-
searchableDefaults
Configures the lookup to be searchable and configures the endpoint to map over the default `q` and `cq` parameters. This is compatible with the standard pattern for searchable endpoints. If the endpoint being searched against supports a non-standard pattern, thensearchable(boolean)
should be used and thereadEndpoint(UnaryOperator)
configured with the parameters.- Returns:
- this
-
notSearchable
Configures the lookup to not be searchable. This is the default ifsearchable()
is not used.- Returns:
- this
-
multi
Configures whether or not the lookup supports multi-selection.- Returns:
- this
-
multi
Configures this lookup to support multi-selection. This is useful for situations where the user should be able to select one or more options.For configurations where
valueSelection()
is chosen, the selected options will have their values persisted in an array.For configurations where
optionSelection()
is chosen, the selected options will themselves be stored in an array.- Returns:
- this
-
notMulti
Configures this lookup to not support multi-selection.- Returns:
- this
-
selectionType
Sets theLookupField.Attributes.SELECTION_TYPE
for this lookup. This attribute drives the way in which the option chosen by the user is persisted within the form state.- Parameters:
selectionType
- the modal component name- Returns:
- this
- See Also:
-
valueSelection
Configures the lookup with theLookupField.SelectionTypes.VALUE
selection type. This engages behavior that will cause only the selected option's value to be stored within the form state for this field.Note, the value of the selected option is driven by the
valueKey(String)
, which defaults to "id".- Returns:
- this
-
optionSelection
Configures the lookup with theLookupField.SelectionTypes.OPTION
selection type. This engages behavior that will cause the entire selected option to be stored within the form state for this field.Note, the option that is stored may be different from the data selected if this lookup is configured with
transformSelection(Mapping[])
, as that transforms the selected value before persistence.- Returns:
- this
-
transformSelection
Configure a set ofMapping
to transform the option the user selects before the form state is updated. ForLookupField.SelectionTypes.OPTION
, this can be used to transform the chosen option into a new structure. ForLookupField.SelectionTypes.VALUE
, this can be used to map over additional properties from the chosen option outside of the option's value.- Returns:
- this
-
transformSelection
Configure a set ofMapping
to transform the option the user selects before the form state is updated. ForLookupField.SelectionTypes.OPTION
, this can be used to transform the chosen option into a new structure. ForLookupField.SelectionTypes.VALUE
, this can be used to map over additional properties from the chosen option outside of the option's value.- Returns:
- this
-
transformSelection
Configure a set ofMapping
to transform the option the user selects before the form state is updated. ForLookupField.SelectionTypes.OPTION
, this can be used to transform the chosen option into a new structure. ForLookupField.SelectionTypes.VALUE
, this can be used to map over additional properties from the chosen option outside of the option's value.- Returns:
- this
-
removeSelectionTransforms
Remove any existing transformations added bytransformSelection(com.broadleafcommerce.metadata.dsl.core.Mapping<?>...)
. -
labelKey
Sets the name of the label key. Defaults to {@link "name"}. It can contain the template to create more complicated labels. * For example to display the label like `Name (id)` the template like `${name} - (${id})` can be used.- Parameters:
labelKey
- the label key- Returns:
- this
-
valueKey
Sets the name of the value key. Defaults to {@link "id"}.- Parameters:
valueKey
- the label key- Returns:
- this
-
loadingMessage
Configure the message to be displayed while the lookup is loading it's options.- Parameters:
loadingMessageKey
- the label key- Returns:
- this
-
noOptionsMessage
Configure the message to be displayed when the lookup finds no options.- Parameters:
noOptionsMessageKey
- the label key- Returns:
- this
-
selectComponent
Sets the name of the React component that will be used for rendering the select input. This is generally used for more advanced lookups that require a more complicated interface.- Parameters:
selectComponentName
- the modal component name- Returns:
- this
-
modalComponent
Sets the name of the React component that will be used for rendering the modal search. This is generally used for more advanced lookups that require a more complicated interface.Note, you must configure the modal component metadata using
modalSearch(java.util.function.UnaryOperator<com.broadleafcommerce.metadata.dsl.core.extension.fields.LookupFieldModal<?>>)
- Parameters:
modalComponent
- the modal component name- Returns:
- this
-
modalToggleLabel
Configures the label for the modal search toggle.Note, you must configure the modal component metadata using
modalSearch(java.util.function.UnaryOperator<com.broadleafcommerce.metadata.dsl.core.extension.fields.LookupFieldModal<?>>)
- Parameters:
modalLabelKey
- the message key- Returns:
- this
-
findModal
Finds the metadata for theLookupField.ViewTypes.LOOKUP_MODAL
configured for this lookup.Note, the metadata this retrieves can be configured using
modalSearch(java.util.function.UnaryOperator<com.broadleafcommerce.metadata.dsl.core.extension.fields.LookupFieldModal<?>>)
.- Returns:
- the optional with lookup field modal or empty
-
modalSearch
Configure this lookup with a modal for more advanced searching. This will result in an additional toggle button being rendered that, upon clicking, will provide the user with a modal that includes a filterable list grid of options. This is primarily used in instances where the text search within the lookup select is not sufficient on its own.Note, you can use
modalComponent(java.lang.String)
to configure a custom React component for the modal, ormodalToggleLabel(java.lang.String)
to configure the label for the modal toggle button. Lastly, modal search can be disabled again usingnotModalSearch()
.- Parameters:
fn
- a function that further configures the search modal- Returns:
- this
-
notModalSearch
Disables modal support and remove the Advanced button from the lookup field.- Returns:
- this
-
removeShowModalSearchUnderLookup
-
catalogSelector
Configure the catalog selector to be displayed next to the lookup field in order to hydrate the context with the necessary catalog id parameters for lookup requests.- Returns:
- this
-
removeCatalogSelector
Remove the catalog selector from the lookup field.- Returns:
- this
-