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.
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.
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.
V
The type of data associated with the selected tags.
public void AbstractSuggestBox(SuggestionsStore<T, E, O> store)
AbstractSuggestBox with the specified suggestions store.
store
The suggestions store providing data for the suggest box.
public boolean isAutoSelect()
true if auto-select is enabled, false otherwise.
public C setAutoSelect(boolean autoSelect)
autoSelect
true to enable auto-select, false to disable it.
The concrete suggest box instance.
public int getTypeAheadDelay()
The type-ahead delay in milliseconds.
public void setTypeAheadDelay(int typeAheadDelayInMillis)
typeAheadDelayInMillis
The type-ahead delay in milliseconds.
public String getPlaceholder()
The placeholder text.
public C setPlaceholder(String placeholder)
placeholder
The placeholder text to set.
The suggest box instance.
public DominoElement<HTMLInputElement> getInputElement()
The input element.
public DivElement getFieldInput()
the input element wrapper element of the suggest box
public C withFieldInputWrapper(ChildHandler<C, DivElement> handler)
handler
function to apply
same suggestbox instance
public C focus()
The suggest box instance.
public C unfocus()
The suggest box instance.
public boolean isFocused()
true if the suggest box is focused, false otherwise.
public boolean isEmpty()
true if the suggest box is empty, false otherwise.
public boolean isEmptyIgnoreSpaces()
true if the suggest box is empty or contains only spaces, false otherwise.
public boolean isEnabled()
true if the suggest box is enabled, false if disabled.
public C clear()
The suggest box instance after clearing the value.
public C clear(boolean silent)
silent
true to clear the value silently, false to trigger change listeners.
The suggest box instance after clearing the value.
public AutoValidator createAutoValidator(ApplyFunction autoValidate)
autoValidate
The auto-validation function to apply.
An AutoValidator instance.
public C triggerChangeListeners(V oldValue, V newValue)
oldValue
The old value before the change.
newValue
The new value after the change.
The suggest box instance.
public C triggerClearListeners(V oldValue)
oldValue
The old value before clearing.
The suggest box instance.
public String getName()
The name of the input element.
public C setName(String name)
name
The name to set for the input element.
The suggest box instance after setting the name.
public String getType()
The input element type ("text").
public C withValue(V value)
value
The value to set.
The suggest box instance after setting the value.
public C withValue(V value, boolean silent)
value
The value to set.
silent
true to set the value silently, false to trigger change listeners.
The suggest box instance after setting the value.
public void setValue(V value)
value
The value to set.
public C setClearable(boolean clearable)
clearable
true to make the suggest box clearable, false otherwise.
The suggest box instance after setting clearability.
public boolean isClearable()
true if the suggest box is clearable, false otherwise.
public C setAutoCloseOnSelect(boolean autoClose)
autoClose
true to auto-close the options menu on selection, false otherwise.
The suggest box instance after configuring auto-closing behavior.
public boolean isAutoCloseOnSelect()
true if auto-closing is enabled, false otherwise.
public Menu<T> getOptionsMenu()
The options menu.
public C withOptionsMenu(ChildHandler<C, Menu<T>> handler)
handler
A handler for configuring the suggest box and options menu.
The suggest box instance after configuring the options menu.
public C setLoader(Loader loader)
loader
same component instance
public C withLoader(ChildHandler<C, Loader> handler)
handler
same component instance
public C withLoaderElement(ChildHandler<C, PrimaryAddOn<HTMLElement>> handler)
handler
same component instance
public void SuggestBox(SuggestionsStore<V, E, O> store)
store
The SuggestionsStore that provides suggestions for this single-select suggest box.
public void SuggestBox(String label, SuggestionsStore<V, E, O> store)
label
The label to display for the single-select suggest box.
store
The SuggestionsStore that provides suggestions for this single-select suggest box.
public static SuggestBox<V, E, O> create(SuggestionsStore<V, E, O> store)
store
The SuggestionsStore that provides suggestions for this single-select suggest box.
A new instance of SuggestBox.
public static SuggestBox<V, E, O> create(String label, SuggestionsStore<V, E, O> store)
label
The label to display for the single-select suggest box.
store
The SuggestionsStore that provides suggestions for this single-select suggest box.
A new instance of SuggestBox.
public V getValue()
The selected value.
public void onOptionSelected(O option)
option
The suggestion option that was selected.
public SuggestBox<V, E, O> withOption(O option)
option
The suggestion option to add.
The updated SuggestBox instance.
public SuggestBox<V, E, O> withOption(O option, boolean silent)
option
The suggestion option to add.
silent
Whether to trigger change listeners silently.
The updated SuggestBox instance.
public void onOptionDeselected(O option)
option
The suggestion option that was deselected.
public String getStringValue()
The string representation of the selected value.
public void MultiSuggestBox(SuggestionsStore<V, E, O> store)
store
The SuggestionsStore that provides suggestions for this multi-select suggest box.
public void MultiSuggestBox(String label, SuggestionsStore<V, E, O> store)
label
The label to display for the multi-select suggest box.
store
The SuggestionsStore that provides suggestions for this multi-select suggest box.
public static MultiSuggestBox<V, E, O> create(SuggestionsStore<V, E, O> store)
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.
A new instance of MultiSuggestBox.
public static MultiSuggestBox<V, E, O> create(String label, SuggestionsStore<V, E, O> store)
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.
A new instance of MultiSuggestBox.
public List<V> getValue()
A list of selected values.
public void onOptionSelected(O option)
option
The suggestion option that was selected.
public MultiSuggestBox<V, E, O> withOption(O option)
option
The suggestion option to add.
The updated MultiSuggestBox instance.
public MultiSuggestBox<V, E, O> withOption(O option, boolean silent)
option
The suggestion option to add.
silent
Whether to trigger change listeners silently.
The updated MultiSuggestBox instance.
public void onOptionDeselected(O option)
option
The suggestion option that was deselected.
public String getStringValue()
A comma-separated string of selected values.
public void TagBox(SuggestionsStore<V, Chip, TagOption<V>> store)
store
The SuggestionsStore that provides suggestions for this TagBox.
public void TagBox(String label, SuggestionsStore<V, Chip, TagOption<V>> store)
label
The label to display for the TagBox.
store
The SuggestionsStore that provides suggestions for this TagBox.
public static TagBox<V> create(SuggestionsStore<V, Chip, TagOption<V>> store)
store
The SuggestionsStore that provides suggestions for this TagBox.
A new instance of TagBox.
public static TagBox<V> create(Function<String, V> inputMapper)
inputMapper
A function to map input strings to tag values.
A new instance of TagBox.
public static TagBox<V> create(String label, Function<String, V> inputMapper)
label
The label to display for the TagBox.
inputMapper
A function to map input strings to tag values.
A new instance of TagBox.
public static TagBox<V> create(String label, SuggestionsStore<V, Chip, TagOption<V>> store)
label
The label to display for the TagBox.
store
The SuggestionsStore that provides suggestions for this TagBox.
A new instance of TagBox.
public TagBox<V> setRemovable(boolean removable)
removable
true to allow removing tags, false otherwise.
The updated TagBox instance.
public boolean isRemovable()
true if tags are removable, false otherwise.
public List<V> getValue()
The list of selected tag values.
public void onOptionSelected(TagOption<V> option)
option
The tag option that was selected.
public void onOptionDeselected(TagOption<V> option)
option
The tag option that was deselected.
public TagBox<V> setReadOnly(boolean readOnly)
readOnly
true` to set the TagBox as read-only, `false` otherwise.
The updated TagBox instance.
public TagBox<V> setDisabled(boolean disabled)
disabled
`true` to set the TagBox as disabled, `false` otherwise.
The updated TagBox instance.
public List<TagOption<V>> getSelectedOptions()
The list of selected tag options.
public String getStringValue()
The string representation of the selected tag values.