1. Domino UI
  2. Forms
  3. Select
Top Basic Docs

Select

Abstract select

Represents an abstract select form element which can be used as a base for building dropdown selectors. This abstract class encapsulates common behavior and rendering logic shared by various select components.

Usage:

 
 // Create a concrete class extending AbstractSelect
 public class MySelect extends AbstractSelect< MyType, String, MyElement, MyOption, MySelect> {
      // implementation details...
 }
 MySelect select = new MySelect();

 

T

The type of the model.

V

The type of the value to be selected.

E

The type of the element.

O

The type of the option.

C

The type of the concrete class extending this abstract class.

Single select

Represents a dropdown select control allowing the user to choose a single option from a list.

Usage example:

 
 Select< String>  fruitSelect = Select.create("Choose a fruit");
 fruitSelect.withOption(new SelectOption<> ("Apple"), false);
 fruitSelect.withOption(new SelectOption<> ("Banana"), false);
 

V

The type of value associated with each select option.

See also :

Multi select

Represents a multi-selection dropdown menu UI component, allowing users to select multiple options.

Usage example:

 
 MultiSelect< String>  multiSelect = MultiSelect.create("Select Items");
 multiSelect.withValue("Option1", "Option2");
 

V

the type of the value represented by each selectable option

See also :

Examples

Select Works in single or multi selection modes.

API Docs: AbstractSelect

Constructors

public void AbstractSelect()
Default constructor which initializes the underlying structures, sets up event listeners, and styles the select form.

Public methods

public C appendChild(O option)
Appends the specified option to the select.

option

The option to be added to the select.



Returns:

an instance of the concrete class.

public C insertChild(int index, O option)
Insert the specified option in the specified index.

index

The desired location index.

option

The option to be added to the select.



Returns:

an instance of the concrete class.

public C appendOptions(Collection<O> options)
Appends a collection of options to the select.

options

The collection of options to be added to the select.



Returns:

an instance of the concrete class.

public C insertOptions(int index, Collection<O> options)
Insert a collection of options starting from the provided index.

index

The insert starting index

options

The collection of options to be added to the select.



Returns:

an instance of the concrete class.

public C appendOptions(O[] options)
Appends a series of options to the select.

options

The options to be added to the select.



Returns:

an instance of the concrete class.

public C insertOptions(int index, O[] options)
Insert a series of options to the select at the provided index.

index

The starting insert index.

options

The options to be added to the select.



Returns:

an instance of the concrete class.

public C appendItem(Function<I, O> mapper, I item)
Maps the specified item using the provided mapper function and appends it as an option to the select.

mapper

The function to map the item to an option.

item

The item to be mapped and added as an option to the select.



Returns:

an instance of the concrete class.

public C insertItem(int index, Function<I, O> mapper, I item)
Maps the specified item using the provided mapper function and insert it at the provided index

index

The index

mapper

The function to map the item to an option.

item

The item to be mapped and added as an option to the select.



Returns:

an instance of the concrete class.

public C appendItems(Function<I, O> mapper, Collection<I> items)
Maps each item in the provided collection using the given mapper function and appends them as options to the select.

mapper

The function to map each item to an option.

items

The collection of items to be mapped and added as options to the select.



Returns:

an instance of the concrete class.

public C insertItems(int index, Function<I, O> mapper, Collection<I> items)
Maps each item in the provided collection using the given mapper function and insert them starting from the provided index.

index

The starting insert index.

mapper

The function to map each item to an option.

items

The collection of items to be mapped and added as options to the select.



Returns:

an instance of the concrete class.

public C appendItems(Function<I, O> mapper, I[] items)
Maps each item in the provided series using the given mapper function and appends them as options to the select.

mapper

The function to map each item to an option.

items

The items to be mapped and added as options to the select.



Returns:

an instance of the concrete class.

public C insertItems(int index, Function<I, O> mapper, I[] items)
Maps each item in the provided series using the given mapper function and insert them starting from the provided index.

index

insert starting index.

mapper

The function to map each item to an option.

items

The items to be mapped and added as options to the select.



Returns:

an instance of the concrete class.

public C appendChild(Separator separator)
Appends the specified separator to the select.

separator

The separator to be added between options in the select.



Returns:

an instance of the concrete class.

public C insertChild(int index, Separator separator)
insert the specified separator to the select at the provided index.

index

the insert index.

separator

The separator to be added between options in the select.



Returns:

an instance of the concrete class.

public String getPlaceholder()
Retrieves the current placeholder text from the select.

Returns:

The placeholder text.

public C setPlaceholder(String placeholder)
Sets the placeholder text for the select.

placeholder

The text to be used as a placeholder.



Returns:

an instance of the concrete class.

public DominoElement<HTMLInputElement> getInputElement()
Retrieves the input element associated with the select.

Returns:

The input element.

public String getStringValue()
Returns the string representation of the currently selected value(s) in the select.

Returns:

The string representation of the selected value(s).

public C focus()
Focuses on the input element associated with the select.

Returns:

an instance of the concrete class.

public C unfocus()
Removes focus from the input element associated with the select.

Returns:

an instance of the concrete class.

public boolean isFocused()
Checks if the input element associated with the select currently has focus.

Returns:

true if the element is focused, false otherwise.

public boolean isEmpty()
Determines if the select currently has a value.

Returns:

true if the select is empty, false otherwise.

public boolean isEmptyIgnoreSpaces()
Determines if the select currently has a value while ignoring spaces.

Note: This method currently has the same implementation as isEmpty .

Returns:

true if the select is empty, false otherwise.

public boolean isEnabled()
Checks if the select is enabled.

Returns:

true if the select is enabled, false otherwise.

public C clear()
Clears the current value of the select.

Returns:

an instance of the concrete class.

public C clear(boolean silent)
Clears the current value of the select with the option to notify listeners of the change.

silent

if true , listeners will not be notified of the change.



Returns:

an instance of the concrete class.

public AutoValidator createAutoValidator(ApplyFunction autoValidate)
Creates an AutoValidator for the select element.

autoValidate

The function to be applied for auto-validation.



Returns:

an instance of AutoValidator .

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

oldValue

The old value.

newValue

The new value.



Returns:

an instance of the concrete class.

public C triggerClearListeners(V oldValue)
Triggers all registered clear listeners with the specified old value.

oldValue

The old value.



Returns:

an instance of the concrete class.

public String getName()
Retrieves the name attribute of the input element associated with the select.

Returns:

The name attribute of the input element.

public C setName(String name)
Sets the name attribute for the input element associated with the select.

name

The name to set.



Returns:

an instance of the concrete class.

public String getType()
Retrieves the type attribute of the input element. For this implementation, it always returns "text".

Returns:

The string "text".

public C withValue(V value)
Sets the value for the select. Whether to notify listeners is determined by the current state of change listeners.

value

The new value to set.



Returns:

an instance of the concrete class.

public C addOptionsGroup(Collection<O> options, MenuItemsGroupHandler<T, AbstractMenuItem<T>> groupHandler)
Adds a group of options to the select menu with a provided group handler.

options

The collection of options to add to the group.

groupHandler

The handler for the options group.



Returns:

an instance of the concrete class.

public C group(MenuItemsGroupHandler<T, AbstractMenuItem<T>> groupHandler, Collection<O> options)
Convenience method to group a set of options using a provided group handler. Internally uses addOptionsGroup .

groupHandler

The handler for the options group.

options

The collection of options to group.



Returns:

an instance of the concrete class.

public C withValue(V value, boolean silent)
Sets the value for the select. Optionally, it can notify listeners based on the provided silent flag.

value

The new value to set.

silent

If true, change listeners will not be notified.



Returns:

an instance of the concrete class.

public C withOption(O option)
Appends an option to the select. Whether to notify listeners is determined by the current state of change listeners.

option

The option to add.



Returns:

an instance of the concrete class.

public void setValue(V value)
Sets the value of the select component.

value

The new value to set.

public C selectOption(O option)
Selects a given option within the select component.

option

The option to select.



Returns:

an instance of the concrete class.

public int getSelectedIndex()
Retrieves the index of the currently selected option within the select component. If no option is selected, it returns -1.

Returns:

The index of the selected option, or -1 if no option is selected.

public Optional<O> findOption(O option)
Searches for a specific option within the select component.

option

The option to search for.



Returns:

An Optional containing the matched option or empty if not found.

public Optional<O> findOptionByKey(String key)
Searches for an option by its key within the select component.

key

The key of the option to search for.



Returns:

An Optional containing the matched option or empty if not found.

public Optional<O> findOptionByValue(T value)
Searches for an option by its value within the select component.

value

The value of the option to search for.



Returns:

An Optional containing the matched option or empty if not found.

public Optional<O> findOptionByIndex(int index)
Searches for an option by its index within the select component.

index

The index of the option to search for.



Returns:

An Optional containing the matched option or empty if the index is out of bounds or not found.

public C selectAt(int index)
Selects the option at the specified index within the select component.

index

The index of the option to select.



Returns:

an instance of the concrete class.

public C selectAt(int[] indices)
Selects the option at the specified Indices within the select component.

indices

The Indices of the options to select.



Returns:

an instance of the concrete class.

public C selectAt(int index, boolean silent)
Selects the option at the specified index within the select component. Optionally, it can notify listeners based on the provided silent flag.

index

The index of the option to select.

silent

If true, change listeners will not be notified.



Returns:

an instance of the concrete class.

public C selectAt(boolean silent, int[] indices)
Selects the option at the specified Indices within the select component. Optionally, it can notify listeners based on the provided silent flag.

indices

The Indices of the option to select.

silent

If true, change listeners will not be notified.



Returns:

an instance of the concrete class.

public C selectByKey(String key)
Selects the option associated with the specified key within the select component. Note: This method erroneously calls onOptionDeselected instead of onOptionSelected.

key

The key of the option to select.



Returns:

an instance of the concrete class.

public C selectByKey(String key, boolean silent)
Selects the option associated with the specified key within the select component. Note: This method erroneously calls onOptionDeselected instead of onOptionSelected. Optionally, it can notify listeners based on the provided silent flag.

key

The key of the option to select.

silent

If true, change listeners will not be notified.



Returns:

an instance of the concrete class.

public C selectByValue(T value)
Selects the option with the specified value within the select component.

value

The value of the option to select.



Returns:

an instance of the concrete class.

public C selectByValue(T value, boolean silent)
Selects the option with the specified value within the select component. Optionally, it can notify listeners based on the provided silent flag.

value

The value of the option to select.

silent

If true, change listeners will not be notified.



Returns:

an instance of the concrete class.

public C deselectAt(int index)
Deselects the option at the specified index within the select component.

index

The index of the option to deselect.



Returns:

an instance of the concrete class.

public C deselectAt(int index, boolean silent)
Deselects the option at the specified index within the select component. Optionally, it can notify listeners based on the provided silent flag.

index

The index of the option to deselect.

silent

If true, change listeners will not be notified.



Returns:

an instance of the concrete class.

public C deselectByKey(String key)
Deselects the option associated with the specified key within the select component. Optionally, it can notify listeners based on the provided silent flag.

key

The key of the option to deselect.



Returns:

an instance of the concrete class.

public C deselectByKey(String key, boolean silent)
Deselects the option associated with the specified key within the select component. Optionally, it can notify listeners based on the provided silent flag.

key

The key of the option to deselect.

silent

If true, change listeners will not be notified.



Returns:

an instance of the concrete class.

public C deselectByValue(T value)
Deselects the option with the specified value within the select component.

value

The value of the option to deselect.



Returns:

an instance of the concrete class.

public C deselectByValue(T value, boolean silent)
Deselects the option with the specified value within the select component. Optionally, it can notify listeners based on the provided silent flag.

value

The value of the option to deselect.

silent

If true, change listeners will not be notified.



Returns:

an instance of the concrete class.

public boolean containsKey(String key)
Checks if the select component contains an option with the specified key.

key

The key to search for.



Returns:

true if the option is found, otherwise false .

public boolean containsValue(T value)
Checks if the select component contains an option with the specified value.

value

The value to search for.



Returns:

true if the option is found, otherwise false .

public C setClearable(boolean clearable)
Sets whether the select component can be cleared.

clearable

true if the select should be clearable, otherwise false .



Returns:

an instance of the concrete class.

public boolean isClearable()
Checks if the select component can be cleared.

Returns:

true if the select is clearable, otherwise false .

public C setAutoCloseOnSelect(boolean autoClose)
Configures whether the select component should automatically close upon selecting an option.

autoClose

true if the select should automatically close after selection, otherwise false .



Returns:

an instance of the concrete class.

public boolean isAutoCloseOnSelect()
Checks if the select component is set to automatically close upon selecting an option.

Returns:

true if the select auto-closes on select, otherwise false .

public C setSearchable(boolean searchable)
Configures whether the select component should provide a search functionality for its options.

searchable

true if the select should provide search functionality, otherwise false .



Returns:

an instance of the concrete class.

public boolean isSearchable()
Checks if the select component provides a search functionality.

Returns:

true if the select is searchable, otherwise false .

public boolean isAllowCreateMissing()
Checks if the select component allows creation of missing options.

Returns:

true if the select allows creating missing options, otherwise false .

public Menu<T> getOptionsMenu()
Retrieves the options menu associated with the select component.

Returns:

The options menu.

public C withOptionsMenu(ChildHandler<C, Menu<T>> handler)
Applies a handler to the options menu of the select component.

handler

The handler to apply.



Returns:

an instance of the concrete class.

public C setMissingItemHandler(MissingOptionHandler<C, E, T, O> missingOptionHandler)
Sets the handler for missing options in the select component.

missingOptionHandler

The handler for missing options.



Returns:

an instance of the concrete class.

public C removeOption(O option)
Removes a specified option from the select component.

option

The option to remove.



Returns:

an instance of the concrete class.

public C removeOptionAt(int index)
Removes a specified option from the select component.

index

the index of the option to be removed.



Returns:

an instance of the concrete class.

public C removeOptions(Collection<O> options)
Removes a collection of options from the select component.

options

The collection of options to remove.



Returns:

an instance of the concrete class.

public C removeOptions(O[] options)
Removes an array of options from the select component.

options

The array of options to remove.



Returns:

an instance of the concrete class.

public C removeAllOptions()
Removes all options from the select component.

Returns:

an instance of the concrete class.

public C hide()
Hides the select component. If the options menu is open, it will be closed before hiding.

Returns:

an instance of the concrete class.

public boolean isTypeToSelect()
is the select component selectable by typing.

Returns:

true if the select component is selectable when start typing

public C setTypeToSelect(boolean typeToSelect)
Sets the select component to be selectable by typing.

typeToSelect

true if the select component should be selectable when start typing

public List<O> getOptions()
Retrieves a list of options by processing the flat menu items from the options menu. The method filters and maps each menu item's metadata into a corresponding option.

Returns:

a list of options collected from the menu items

public C withOptions(ChildHandler<C, List<O>> handler)
Configures the current instance with the provided options handler.

handler

the handler responsible for applying additional options to the current instance and its associated list of options



Returns:

the current instance with the applied options

public C withFieldInput(ChildHandler<C, DivElement> handler)
Processes the provided handler with the current instance and the fieldInput element.

handler

a ChildHandler that performs actions using the current instance and the fieldInput element



Returns:

the current instance after the handler is applied

API Docs: Select

Constructors

public void Select()
Default constructor creating a Select instance without a label.
public void Select(String label)
Constructor to create a Select instance with the specified label.

label

The label to be set for the select control.

Static methods

public static Select<V> create()
Creates a new instance of Select without a label.

V

the type of value for the select options



Returns:

a new instance of Select

public static Select<V> create(String label)
Creates a new instance of Select with a specified label.

label

The label to be set for the select control.

V

the type of value for the select options



Returns:

a new instance of Select with the specified label.

Public methods

public Select<V> withOption(SelectOption<V> option, boolean silent)
Adds an option to the Select dropdown. If the option value is different from the current selected value, it updates the selected option.

option

The option to be added.

silent

If true, does not trigger change listeners after setting the option.



Returns:

The current Select instance.

public V getValue()
Retrieves the value of the currently selected option.

Returns:

the value of the currently selected option or null if no option is selected.

API Docs: MultiSelect

Constructors

public void MultiSelect()
Default constructor initializing the options menu for multi-selection.
public void MultiSelect(String label)
Constructor with a predefined label.

label

the label for the MultiSelect

Static methods

public static MultiSelect<V> create()
Creates a new instance of MultiSelect without any predefined label.

V

the type of the value



Returns:

a new instance of MultiSelect

public static MultiSelect<V> create(String label)
Creates a new instance of MultiSelect with a predefined label.

label

the label for the MultiSelect

V

the type of the value



Returns:

a new instance of MultiSelect

Public methods

public MultiSelect<V> withValue(V[] value)
Sets the value(s) of this MultiSelect .

value

the values to set



Returns:

the current MultiSelect instance for chaining

public MultiSelect<V> withValue(boolean silent, V[] value)
Sets the value(s) for this MultiSelect with the ability to silence the change listeners.

This method allows specifying multiple values and whether the change should notify listeners or not.

Usage example:

 
 MultiSelect< String>  multiSelect = MultiSelect.create("Select Items");
 multiSelect.withValue(true, "Option1", "Option2"); // silent set
 multiSelect.withValue(false, "Option3", "Option4"); // non-silent set
 

silent

if true , change listeners will not be triggered; if false , they will be triggered

value

the array of values to set



Returns:

the current MultiSelect instance for chaining

See also :

public MultiSelect<V> withOption(SelectOption<V> option, boolean silent)
Adds an option to the MultiSelect .

option

the option to add

silent

if true, change listeners will not be triggered



Returns:

the current MultiSelect instance for chaining

public List<V> getValue()
Retrieves a list of values representing all the selected options.

Returns:

a list of selected values

See also :

public MultiSelect<V> setWrapSelection(boolean wrapSelection)
Sets whether the selection should wrap or not.

If wrapSelection is true , the selection will wrap. Otherwise, it will be forced to stay on a single line using a no-wrap CSS class.

wrapSelection

true to allow wrapping, false to prevent wrapping



Returns:

this MultiSelect instance for method chaining

public MultiSelect<V> setShowSelectionCount(boolean showSelectionCount)
Sets whether the selection count badge should be visible.

If showSelectionCount is true , the selection count badge will be shown. Otherwise, it will be hidden using the appropriate CSS class.

showSelectionCount

true to display the selection count badge, false to hide it



Returns:

this MultiSelect instance for method chaining

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

Donate & Support Us