1. Domino UI
  2. Forms
  3. Suggest Box
Top Suggest box Tags box Docs

Suggest box

Abstract suggest

An abstract base class for suggest box elements that provides common functionality and UI components.

This class allows the creation of suggest boxes for selecting options from a list of suggestions. It provides features like auto-suggest, delayed text input, and a drop-down menu for selecting options.

Usage Example:

 
 // Create a suggest box with a custom SuggestionsStore
 SuggestionsStore< MyData, IsElement< ?>> suggestionsStore = createCustomSuggestionsStore();
 MySuggestBox suggestBox = new MySuggestBox(suggestionsStore);
 suggestBox.setPlaceholder("Search..."); suggestBox.setAutoSelect(true);
 suggestBox.setTypeAheadDelay(500); suggestBox.addSelectionListener(selectedOption -> { MyData
 selectedData = selectedOption.getValue(); // Handle the selected data });
 

T

The data type of the suggest options.

V

The value type of the suggest box.

E

The type of the suggest box's element, usually an IsElement .

O

The type of options that can be selected in the suggest box.

C

The concrete suggest box implementation type.

Single suggest

A single-select suggestion box that allows users to select an option from a list of suggestions.

V

The type of data associated with the selected option.

E

The type of the suggest box's element.

O

The type of the option within the suggest box.

Multi suggest

A multi-select suggestion box that allows users to select multiple options from a list of suggestions.

V

The type of data associated with the selected options.

E

The type of the suggest box's element.

O

The type of the option within the suggest box.

Tags box

A versatile input field that allows users to select multiple tags from a list of suggestions.

V

The type of data associated with the selected tags.

Examples

Suggest box Optionally select one or more suggested values.

Tags box Input multi value data as tags.

API Docs: AbstractSuggestBox

Constructors

public void AbstractSuggestBox(SuggestionsStore<T, E, O> store)
Creates an instance of AbstractSuggestBox with the specified suggestions store.

store

The suggestions store providing data for the suggest box.

Public methods

public boolean isAutoSelect()
Checks if auto-select is enabled.

Returns:

true if auto-select is enabled, false otherwise.

public C setAutoSelect(boolean autoSelect)
Sets whether auto-select is enabled or disabled.

autoSelect

true to enable auto-select, false to disable it.



Returns:

The concrete suggest box instance.

public int getTypeAheadDelay()
Gets the type-ahead delay in milliseconds; this will return the value specified using setTypeAheadDelay if greater than 0 otherwise, this will return the value specified in getSuggestBoxTypeAheadDelay .

Returns:

The type-ahead delay in milliseconds.

public void setTypeAheadDelay(int typeAheadDelayInMillis)
Sets the type-ahead delay in milliseconds.

typeAheadDelayInMillis

The type-ahead delay in milliseconds.

public String getPlaceholder()
Gets the placeholder text of the input element.

Returns:

The placeholder text.

public C setPlaceholder(String placeholder)
Sets the placeholder text of the input element.

placeholder

The placeholder text to set.



Returns:

The suggest box instance.

public DominoElement<HTMLInputElement> getInputElement()
Gets the input element of the suggest box as a DominoElement.

Returns:

The input element.

public DivElement getFieldInput()


Returns:

the input element wrapper element of the suggest box

public C withFieldInputWrapper(ChildHandler<C, DivElement> handler)
Applies a function to the input element wrapper of the suggest box.

handler

function to apply



Returns:

same suggestbox instance

public C focus()
Focuses on the suggest box input element.

Returns:

The suggest box instance.

public C unfocus()
Unfocuses (blurs) the suggest box input element.

Returns:

The suggest box instance.

public boolean isFocused()
Checks if the suggest box is currently focused.

Returns:

true if the suggest box is focused, false otherwise.

public boolean isEmpty()
Checks if the suggest box is empty, meaning there are no selected options.

Returns:

true if the suggest box is empty, false otherwise.

public boolean isEmptyIgnoreSpaces()
Checks if the suggest box is empty (ignoring spaces).

Returns:

true if the suggest box is empty or contains only spaces, false otherwise.

public boolean isEnabled()
Checks if the suggest box is enabled.

Returns:

true if the suggest box is enabled, false if disabled.

public C clear()
Clears the current value of the suggest box. This method is used to clear the selected options.

Returns:

The suggest box instance after clearing the value.

public C clear(boolean silent)
Clears the current value of the suggest box. This method is used to clear the selected options.

silent

true to clear the value silently, false to trigger change listeners.



Returns:

The suggest box instance after clearing the value.

public AutoValidator createAutoValidator(ApplyFunction autoValidate)
Creates an auto-validator for the suggest box.

autoValidate

The auto-validation function to apply.



Returns:

An AutoValidator instance.

public C triggerChangeListeners(V oldValue, V newValue)
Triggers change listeners with the old and new values.

oldValue

The old value before the change.

newValue

The new value after the change.



Returns:

The suggest box instance.

public C triggerClearListeners(V oldValue)
Triggers clear listeners with the old value before clearing.

oldValue

The old value before clearing.



Returns:

The suggest box instance.

public String getName()
Gets the name of the suggest box input element.

Returns:

The name of the input element.

public C setName(String name)
Sets the name of the suggest box input element.

name

The name to set for the input element.



Returns:

The suggest box instance after setting the name.

public String getType()
Gets the type of the suggest box input element. It always returns "text" since this is a text input.

Returns:

The input element type ("text").

public C withValue(V value)
Sets the value of the suggest box.

value

The value to set.



Returns:

The suggest box instance after setting the value.

public C withValue(V value, boolean silent)
Sets the value of the suggest box.

value

The value to set.

silent

true to set the value silently, false to trigger change listeners.



Returns:

The suggest box instance after setting the value.

public void setValue(V value)
Sets the value of the suggest box.

value

The value to set.

public C setClearable(boolean clearable)
Sets whether the suggest box is clearable or not.

clearable

true to make the suggest box clearable, false otherwise.



Returns:

The suggest box instance after setting clearability.

public boolean isClearable()
Checks if the suggest box is clearable.

Returns:

true if the suggest box is clearable, false otherwise.

public C setAutoCloseOnSelect(boolean autoClose)
Sets whether the suggest box should auto-close the options menu when an option is selected.

autoClose

true to auto-close the options menu on selection, false otherwise.



Returns:

The suggest box instance after configuring auto-closing behavior.

public boolean isAutoCloseOnSelect()
Checks if the suggest box is configured to auto-close the options menu when an option is selected.

Returns:

true if auto-closing is enabled, false otherwise.

public Menu<T> getOptionsMenu()
Gets the options menu associated with the suggest box.

Returns:

The options menu.

public C withOptionsMenu(ChildHandler<C, Menu<T>> handler)
Configures the suggest box with the provided options menu using the provided handler.

handler

A handler for configuring the suggest box and options menu.



Returns:

The suggest box instance after configuring the options menu.

public C setLoader(Loader loader)
Use to change the default search loader of a suggest box.

loader



Returns:

same component instance

public C withLoader(ChildHandler<C, Loader> handler)
Use to apply a function on search loader of a suggest box.

handler



Returns:

same component instance

public C withLoaderElement(ChildHandler<C, PrimaryAddOn<HTMLElement>> handler)
Use to apply a function on element hosting the suggest box search loader.

handler



Returns:

same component instance

API Docs: SuggestBox

Constructors

public void SuggestBox(SuggestionsStore<V, E, O> store)
Creates a new instance of SuggestBox with the provided SuggestionsStore.

store

The SuggestionsStore that provides suggestions for this single-select suggest box.

public void SuggestBox(String label, SuggestionsStore<V, E, O> store)
Creates a new instance of SuggestBox with a label and the provided SuggestionsStore.

label

The label to display for the single-select suggest box.

store

The SuggestionsStore that provides suggestions for this single-select suggest box.

Static methods

public static SuggestBox<V, E, O> create(SuggestionsStore<V, E, O> store)
Creates a new instance of SuggestBox with the provided SuggestionsStore.

store

The SuggestionsStore that provides suggestions for this single-select suggest box.



Returns:

A new instance of SuggestBox.

public static SuggestBox<V, E, O> create(String label, SuggestionsStore<V, E, O> store)
Creates a new instance of SuggestBox with a label and the provided SuggestionsStore.

label

The label to display for the single-select suggest box.

store

The SuggestionsStore that provides suggestions for this single-select suggest box.



Returns:

A new instance of SuggestBox.

Public methods

public V getValue()
Retrieves the currently selected value.

Returns:

The selected value.

public void onOptionSelected(O option)
Handles the selection of a suggestion option.

option

The suggestion option that was selected.

public SuggestBox<V, E, O> withOption(O option)
Adds a suggestion option to the single-select suggest box.

option

The suggestion option to add.



Returns:

The updated SuggestBox instance.

public SuggestBox<V, E, O> withOption(O option, boolean silent)
Adds a suggestion option to the single-select suggest box.

option

The suggestion option to add.

silent

Whether to trigger change listeners silently.



Returns:

The updated SuggestBox instance.

public void onOptionDeselected(O option)
Handles the deselection of a suggestion option.

option

The suggestion option that was deselected.

public String getStringValue()
Retrieves the string representation of the selected value.

Returns:

The string representation of the selected value.

API Docs: MultiSuggestBox

Constructors

public void MultiSuggestBox(SuggestionsStore<V, E, O> store)
Creates a new instance of MultiSuggestBox with the provided SuggestionsStore.

store

The SuggestionsStore that provides suggestions for this multi-select suggest box.

public void MultiSuggestBox(String label, SuggestionsStore<V, E, O> store)
Creates a new instance of MultiSuggestBox with a label and the provided SuggestionsStore.

label

The label to display for the multi-select suggest box.

store

The SuggestionsStore that provides suggestions for this multi-select suggest box.

Static methods

public static MultiSuggestBox<V, E, O> create(SuggestionsStore<V, E, O> store)
Creates a new MultiSuggestBox instance with the provided SuggestionsStore.

V

The type of data associated with the selected options.

E

The type of the suggest box's element.

O

The type of the option within the suggest box.

store

The SuggestionsStore that provides suggestions for this multi-select suggest box.



Returns:

A new instance of MultiSuggestBox.

public static MultiSuggestBox<V, E, O> create(String label, SuggestionsStore<V, E, O> store)
Creates a new MultiSuggestBox instance with a label and the provided SuggestionsStore.

V

The type of data associated with the selected options.

E

The type of the suggest box's element.

O

The type of the option within the suggest box.

label

The label to display for the multi-select suggest box.

store

The SuggestionsStore that provides suggestions for this multi-select suggest box.



Returns:

A new instance of MultiSuggestBox.

Public methods

public List<V> getValue()
Retrieves the currently selected values as a list.

Returns:

A list of selected values.

public void onOptionSelected(O option)
Handles the selection of a suggestion option.

option

The suggestion option that was selected.

public MultiSuggestBox<V, E, O> withOption(O option)
Adds a suggestion option to the multi-select suggest box.

option

The suggestion option to add.



Returns:

The updated MultiSuggestBox instance.

public MultiSuggestBox<V, E, O> withOption(O option, boolean silent)
Adds a suggestion option to the multi-select suggest box.

option

The suggestion option to add.

silent

Whether to trigger change listeners silently.



Returns:

The updated MultiSuggestBox instance.

public void onOptionDeselected(O option)
Handles the deselection of a suggestion option.

option

The suggestion option that was deselected.

public String getStringValue()
Retrieves the string representation of the selected values.

Returns:

A comma-separated string of selected values.

API Docs: TagBox

Constructors

public void TagBox(SuggestionsStore<V, Chip, TagOption<V>> store)
Creates a new instance of TagBox with the provided SuggestionsStore.

store

The SuggestionsStore that provides suggestions for this TagBox.

public void TagBox(String label, SuggestionsStore<V, Chip, TagOption<V>> store)
Creates a new instance of TagBox with a label and the provided SuggestionsStore.

label

The label to display for the TagBox.

store

The SuggestionsStore that provides suggestions for this TagBox.

Static methods

public static TagBox<V> create(SuggestionsStore<V, Chip, TagOption<V>> store)
Creates a new instance of TagBox with the provided SuggestionsStore.

store

The SuggestionsStore that provides suggestions for this TagBox.



Returns:

A new instance of TagBox.

public static TagBox<V> create(Function<String, V> inputMapper)
Creates a new instance of TagBox with a default input mapper.

inputMapper

A function to map input strings to tag values.



Returns:

A new instance of TagBox.

public static TagBox<V> create(String label, Function<String, V> inputMapper)
Creates a new instance of TagBox with a label and a default input mapper.

label

The label to display for the TagBox.

inputMapper

A function to map input strings to tag values.



Returns:

A new instance of TagBox.

public static TagBox<V> create(String label, SuggestionsStore<V, Chip, TagOption<V>> store)
Creates a new instance of TagBox with a label and the provided SuggestionsStore.

label

The label to display for the TagBox.

store

The SuggestionsStore that provides suggestions for this TagBox.



Returns:

A new instance of TagBox.

Public methods

public TagBox<V> setRemovable(boolean removable)
Sets whether the tags are removable.

removable

true to allow removing tags, false otherwise.



Returns:

The updated TagBox instance.

public boolean isRemovable()
Checks if tags are removable.

Returns:

true if tags are removable, false otherwise.

public List<V> getValue()
Retrieves the list of selected tag values.

Returns:

The list of selected tag values.

public void onOptionSelected(TagOption<V> option)
Handles the selection of a tag option.

option

The tag option that was selected.

public void onOptionDeselected(TagOption<V> option)
Handles the deselection of a tag option.

option

The tag option that was deselected.

public TagBox<V> setReadOnly(boolean readOnly)
Sets the read-only state of the TagBox.

readOnly

true` to set the TagBox as read-only, `false` otherwise.



Returns:

The updated TagBox instance.

public TagBox<V> setDisabled(boolean disabled)
Sets the disabled state of the TagBox.

disabled

`true` to set the TagBox as disabled, `false` otherwise.



Returns:

The updated TagBox instance.

public List<TagOption<V>> getSelectedOptions()
Retrieves a list of selected tag options.

Returns:

The list of selected tag options.

public String getStringValue()
Retrieves the string representation of the selected tag values.

Returns:

The string representation of the selected tag values.

We are a group of passionate people who love what we do

Donate & Support Us