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 classstatic final classstatic final classThis enum represents the way in which the lookup selections are persisted within the form state.static final classNested classes/interfaces inherited from interface com.broadleafcommerce.metadata.dsl.core.extension.Dependent
Dependent.DependentFieldsList -
Method Summary
Modifier and TypeMethodDescriptiondefault FConfigure 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 FConfigures the lookup as creatable.default Fcreatable(boolean isCreatable) Configures whether the lookup is creatable.default Optional<LookupFieldModal<?>>Finds the metadata for theLookupField.ViewTypes.LOOKUP_MODALconfigured for this lookup.default Optional<PageableEndpoint<?>>default Endpoint<?>default PageableEndpoint<?>default FhydrateEndpoint(Endpoint<?> endpoint) Configures the hydration endpoint for the lookup.default FhydrateEndpoint(UnaryOperator<Endpoint<?>> fn) Configures the hydration endpoint for the lookup.default FhydrateScope(String scope) ConfigureshydrateEndpoint(UnaryOperator)url.default FhydrateUrl(String url) ConfigureshydrateEndpoint(UnaryOperator)url.default FhydrateUrl(String url, String scope) ConfigureshydrateEndpoint(UnaryOperator)url and scope.default booleandefault FSets the name of the label key.default FloadingMessage(String loadingMessageKey) Configure the message to be displayed while the lookup is loading it's options.default FmodalComponent(String modalComponent) Sets the name of the React component that will be used for rendering the modal search.default FmodalSearch(UnaryOperator<LookupFieldModal<?>> fn) Configure this lookup with a modal for more advanced searching.default FmodalToggleLabel(String modalLabelKey) Configures the label for the modal search toggle.default Fmulti()Configures this lookup to support multi-selection.default Fmulti(boolean isMulti) Configures whether or not the lookup supports multi-selection.default FnoOptionsMessage(String noOptionsMessageKey) Configure the message to be displayed when the lookup finds no options.default FDisables modal support and remove the Advanced button from the lookup field.default FnotMulti()Configures this lookup to not support multi-selection.default FConfigures the lookup to not be searchable.default FConfigures the lookup with theLookupField.SelectionTypes.OPTIONselection type.default FreadEndpoint(PageableEndpoint<?> endpoint) Configure the read endpoint for the lookup.default FConfigure the read endpoint for the lookup.default FConfiguresreadEndpoint(UnaryOperator)scope.default FConfiguresreadEndpoint(UnaryOperator)url.default FConfiguresreadEndpoint(UnaryOperator)url with scopedefault FRemove the catalog selector from the lookup field.default FRemove any existing transformations added bytransformSelection(com.broadleafcommerce.metadata.dsl.core.Mapping<?>...).default Fdefault FConfigures the lookup to be searchable.default Fsearchable(boolean isSearchable) Configures the lookup to be searchable or notdefault FConfigures the lookup to be searchable and configures the endpoint to map over the default `q` and `cq` parameters.default FselectComponent(String selectComponentName) Sets the name of the React component that will be used for rendering the select input.default FselectionType(String selectionType) Sets theLookupField.Attributes.SELECTION_TYPEfor this lookup.default Fdefault FshowModalSearchUnderLookup(boolean showModalUnderLookup) default FtransformSelection(Mapping<?>... mappings) Configure a set ofMappingto transform the option the user selects before the form state is updated.default FtransformSelection(UnaryOperator<List<Mapping<?>>> fn) Configure a set ofMappingto transform the option the user selects before the form state is updated.default FtransformSelection(List<Mapping<?>> mappings) Configure a set ofMappingto transform the option the user selects before the form state is updated.default FSets the name of the value key.default FConfigures the lookup with theLookupField.SelectionTypes.VALUEselection type.Methods inherited from interface java.lang.Comparable
compareToMethods 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, typeMethods inherited from interface com.broadleafcommerce.metadata.dsl.core.extension.Dependent
clearDependentFields, dependentField, dependentFields, parentIdFieldMethods 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, validationSchemaMethods inherited from interface com.broadleafcommerce.metadata.dsl.core.extension.Filterable
implicitFilter, implicitFilters, implicitFiltersMethods 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, tooltipMethods 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 aPageableEndpointand 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 aPageableEndpointand 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_TYPEfor 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.VALUEselection 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.OPTIONselection 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 ofMappingto 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 ofMappingto 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 ofMappingto 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_MODALconfigured 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
-