1. Domino UI
  2. Components
  3. Lists
Top Single select Multi-Select Docs

Lists

ListGroup

A collection of elements that can be selected and customized grouped in a single list container.

This component provides a container that accepts a collection of elements for viewing with customized content for each one.

For example:

 
     ListGroup.create()
              .setItemRenderer((listGroup, item) ->  {
                  item.appendChild(Label.createPrimary(item.getValue())
              })
              .setItems(Arrays.asList("first item", "second item"));
 

T

the type of the value object inside the element

See also :

ListItem

Represents a list item within a ListGroup . This class provides methods for selecting, deselecting, and configuring list items.

Usage example:

 
 ListItem  listItem = ListItem.create("Item 1");
 listItem.addSelectionListener((source, selection) -> {
     // Handle selection event
     if (selection.isSelected()) {
         // Item is selected
     } else {
         // Item is deselected
     }
 });
 

T

The type of value associated with the list item.

See also :

Examples

Single select lists Lists that allow selecting one item only at a time.

Multi-Select lists List can allow selecting multiple items.

API Docs: ListGroup

Constructors

public void ListGroup()
Constructs a ListGroup with bordered style.

Static methods

public static ListGroup<T> create()
Creates a new ListGroup instance.

The list group is initially created with bordered style.

Returns:

a new ListGroup instance.

Public methods

public ListGroup<T> setItemRenderer(ItemRenderer<T> itemRenderer)
Sets the item renderer for this list group.

itemRenderer

The item renderer function.



Returns:

this ListGroup instance.

public ListGroup<T> setItems(List<? extends T> items)
Sets the items in this list group.

items

The list of items to set.



Returns:

this ListGroup instance.

public ListGroup<T> removeAll()
Removes all items from this list group.

Returns:

this ListGroup instance.

public ListGroup<T> addItems(List<? extends T> items)
Adds items to this list group.

items

The list of items to add.



Returns:

this ListGroup instance.

public ListGroup<T> addItem(T value)
Adds a single item to this list group.

value

The item value to add.



Returns:

this ListGroup instance.

public ListGroup<T> insertFirst(T value)
Inserts an item at the beginning of this list group.

value

The item value to insert.



Returns:

this ListGroup instance.

public ListGroup<T> insertAt(int index, T value)
Inserts an item at the specified index in this list group.

index

The index at which to insert the item.

value

The item value to insert.



Returns:

this ListGroup instance.

public ListGroup<T> removeItemsByValue(List<? extends T> toBeRemoved)
Removes items from this list group based on their values.

toBeRemoved

The list of items to remove.



Returns:

this ListGroup instance.

public ListGroup<T> removeItem(T value)
Removes a single item from this list group based on its value.

value

The item value to remove.



Returns:

this ListGroup instance.

public ListGroup<T> removeItem(ListItem<? extends T> item)
Removes a single item from this list group.

item

The item to remove.



Returns:

this ListGroup instance.

public ListGroup<T> removeItems(List<ListItem<? extends T>> items)
Removes multiple items from this list group.

items

The list of items to remove.



Returns:

this ListGroup instance.

public ListGroup<T> removeItem(ListItem<? extends T> item, boolean silent)
Removes a single item from this list group.

item

The item to remove.

silent

Whether to trigger removal listeners.



Returns:

this ListGroup instance.

public ListGroup<T> updateItem(T value)
Updates an item in this list group with a new value.

value

The new value for the item.



Returns:

this ListGroup instance.

public ListGroup<T> updateItems(List<? extends T> newValues)
Updates the items in this list group with new values.

newValues

The list of new values to update.



Returns:

this ListGroup instance.

public ListGroup<T> setBordered(boolean bordered)
Sets whether this list group should have a bordered style.

bordered

Whether to set the bordered style.



Returns:

this ListGroup instance.

public List<ListItem<T>> getItems()
Gets a list of all items in this list group.

Returns:

A list of items.

public List<ListItem<T>> getSelectedItems()
Gets a list of selected items in this list group.

Returns:

A list of selected items.

public ListGroup<T> pauseSelectionListeners()
Pauses the selection listeners, preventing selection and deselection events from being triggered.

Returns:

This ListGroup instance.

public ListGroup<T> resumeSelectionListeners()
Resumes the selection listeners, allowing selection and deselection events to be triggered.

Returns:

This ListGroup instance.

public ListGroup<T> togglePauseSelectionListeners(boolean toggle)
Toggles the pause state of selection listeners based on the given toggle value.

toggle

true to pause selection listeners, false to resume them.



Returns:

This ListGroup instance.

public Set<SelectionListener<? super T, ? super List<T>>> getSelectionListeners()
Retrieves the set of selection listeners registered with this list group.

Returns:

A set of selection listeners.

public Set<SelectionListener<? super T, ? super List<T>>> getDeselectionListeners()
Retrieves the set of deselection listeners registered with this list group.

Returns:

A set of deselection listeners.

public boolean isSelectionListenersPaused()
Checks if the selection listeners are currently paused.

Returns:

true if selection listeners are paused, false otherwise.

public ListGroup<T> triggerSelectionListeners(T source, List<T> selection)
Triggers selection listeners with the given source and selection list.

source

The source of the selection event.

selection

The list of selected items.



Returns:

This ListGroup instance.

public ListGroup<T> triggerDeselectionListeners(T source, List<T> selection)
Triggers deselection listeners with the given source and deselected item list.

source

The source of the deselection event.

selection

The list of deselected items.



Returns:

This ListGroup instance.

public List<T> getSelection()
Retrieves the currently selected items in the list group.

Returns:

A list of selected items.

public List<T> getValues()
Gets a list of values from the items in this list group.

Returns:

A list of values.

public ListGroup<T> select(List<ListItem<T>> items)
Selects a list of items in this list group.

items

The list of items to select.



Returns:

this ListGroup instance.

public ListGroup<T> select(ListItem<T> listItem)
Selects a single item in this list group.

listItem

The item to select.



Returns:

this ListGroup instance.

public ListGroup<T> select(ListItem<T> listItem, boolean silent)
Selects a single item in this list group.

listItem

The item to select.

silent

Whether to suppress selection events.



Returns:

this ListGroup instance.

public ListGroup<T> deselect(List<ListItem<T>> items)
Deselects a list of items in this list group.

items

The list of items to deselect.



Returns:

this ListGroup instance.

public ListGroup<T> deselect(ListItem<T> listItem)
Deselects a single item in this list group.

listItem

The item to deselect.



Returns:

this ListGroup instance.

public ListGroup<T> deselect(ListItem<T> listItem, boolean silent)
Deselects a single item in this list group.

listItem

The item to deselect.

silent

Whether to suppress deselection events.



Returns:

this ListGroup instance.

public boolean isMultiSelect()
Checks if multiple items can be selected simultaneously in this list group.

Returns:

true if multi-select is enabled, false otherwise.

public ListGroup<T> setMultiSelect(boolean multiSelect)
Sets whether multiple items can be selected simultaneously in this list group.

multiSelect

Whether to enable multi-select.



Returns:

this ListGroup instance.

public ListGroup<T> addAddListener(AddListener<T> addListener)
Adds an add listener to this list group.

addListener

The add listener to add.



Returns:

this ListGroup instance.

public ListGroup<T> removeAddListener(AddListener<T> addListener)
Removes an add listener from this list group.

addListener

The add listener to remove.



Returns:

this ListGroup instance.

public ListGroup<T> addRemoveListener(RemoveListener<T> removeListener)
Adds a remove listener to this list group.

removeListener

The remove listener to add.



Returns:

this ListGroup instance.

public ListGroup<T> removeRemoveListener(RemoveListener<T> removeListener)
Removes a remove listener from this list group.

removeListener

The remove listener to remove.



Returns:

this ListGroup instance.

public ListGroup<T> setSelectable(boolean selectable)
Sets whether items in this list group are selectable.

selectable

Whether to set items as selectable.



Returns:

this ListGroup instance.

public boolean isSelectable()
Checks if items in this list group are selectable.

Returns:

true if items are selectable, false otherwise.

public HTMLUListElement element()
Retrieves the underlying HTMLUListElement associated with this ListGroup .

Returns:

The HTMLUListElement representing the list group.

API Docs: ListItem

Constructors

public void ListItem(T value)
Constructs a new `ListItem` with the given value.

value

The value associated with this `ListItem`.

Static methods

public static ListItem<T> create(T value)
Creates a new `ListItem` instance with the specified value.

value

The value associated with this `ListItem`.

T

The type of the value.



Returns:

A new `ListItem` instance.

Public methods

public void bindTo(ListGroup<T> owner)
Binds this `ListItem` to a parent `ListGroup`.

owner

The `ListGroup` to which this `ListItem` will be bound.

public HTMLLIElement element()
Returns the underlying HTML list item element.

Returns:

The HTML list item element.

public T getValue()
Gets the value associated with this list item.

Returns:

The value associated with the list item.

public void setValue(T value)
Sets the value associated with this list item.

value

The value to set.

public ListItem<T> pauseSelectionListeners()
Pauses the execution of selection listeners for this list item.

Returns:

This list item instance with selection listeners paused.

public ListItem<T> resumeSelectionListeners()
Resumes the execution of selection listeners for this list item.

Returns:

This list item instance with selection listeners resumed.

public ListItem<T> togglePauseSelectionListeners(boolean toggle)
Toggles the pause state of selection listeners for this list item.

toggle

true to pause, false to resume.



Returns:

This list item instance with selection listeners paused or resumed based on the toggle value.

public Set<SelectionListener<? super ListItem<T>, ? super ListItem<T>>> getSelectionListeners()
Gets the selection listeners attached to this list item.

Returns:

A set of selection listeners.

public Set<SelectionListener<? super ListItem<T>, ? super ListItem<T>>> getDeselectionListeners()
Gets the deselection listeners attached to this list item.

Returns:

A set of deselection listeners.

public boolean isSelectionListenersPaused()
Checks if selection listeners are currently paused for this list item.

Returns:

true if selection listeners are paused, false otherwise.

public ListItem<T> triggerSelectionListeners(ListItem<T> source, ListItem<T> selection)
Triggers selection listeners for this list item with the provided source and selection.

source

The source of the selection event.

selection

The selected list item.



Returns:

This list item instance.

public ListItem<T> triggerDeselectionListeners(ListItem<T> source, ListItem<T> selection)
Triggers deselection listeners for this list item with the provided source and selection.

source

The source of the deselection event.

selection

The deselected list item.



Returns:

This list item instance.

public ListItem<T> getSelection()
Gets the currently selected list item.

Returns:

This list item if it is selected, or null if it is not selected.

public ListItem<T> select()
Selects this list item if it is selectable.

Returns:

This list item instance with the selection state updated.

public ListItem<T> deselect()
Deselects this list item if it is selectable.

Returns:

This list item instance with the deselection state updated.

public ListItem<T> select(boolean silent)
Selects or deselects this list item based on the provided flag.

silent

true to suppress selection/deselection events, false to trigger them.



Returns:

This list item instance with the selection state updated.

public ListItem<T> deselect(boolean silent)
Deselects this list item if it is selectable, optionally suppressing deselection events.

silent

true to suppress deselection events, false to trigger them.



Returns:

This list item instance with the deselection state updated.

public boolean isSelected()
Checks if this list item is currently selected.

Returns:

true if this list item is selected, false otherwise.

public boolean isSelectable()
Checks if this list item is selectable.

Returns:

true if this list item is selectable, false otherwise.

public ListItem<T> setSelectable(boolean selectable)
Sets whether this list item is selectable.

selectable

true to make this list item selectable, false to make it non-selectable.



Returns:

This list item instance with the selectability state updated.

public ListItem<T> setSelected(boolean selected)
Sets the selected state of this list item.

selected

The new selected state.



Returns:

This list item instance with the selected state updated.

public ListItem<T> setSelected(boolean selected, boolean silent)
Sets the selected state of this list item, optionally suppressing selection/deselection events.

selected

The new selected state.

silent

true to suppress selection/deselection events, false to trigger them.



Returns:

This list item instance with the selected state updated.

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

Donate & Support Us