com.vaadin.flow.component.listbox.
Class ListBox<T>
- java.lang.Object
-
- com.vaadin.flow.component.Component
-
- com.vaadin.flow.component.AbstractField<C,T>
-
- com.vaadin.flow.component.AbstractSinglePropertyField<C,VALUE>
-
- com.vaadin.flow.component.listbox.ListBoxBase<ListBox<T>,T,T>
-
- com.vaadin.flow.component.listbox.ListBox<T>
-
Type Parameters:
T
- the type of the items contained by this componentAll Implemented Interfaces:
AttachNotifier
,DetachNotifier
,HasComponents
,HasElement
,HasEnabled
,HasSize
,HasStyle
,HasValue<AbstractField.ComponentValueChangeEvent<ListBox<T>,T>,T>
,HasValueAndElement<AbstractField.ComponentValueChangeEvent<ListBox<T>,T>,T>
,HasItemComponents<T>
,HasDataView<T,Void,ListBoxDataView<T>>
,HasListDataView<T,ListBoxListDataView<T>>
,SingleSelect<ListBox<T>,T>
,Serializable
public class ListBox<T> extends ListBoxBase<ListBox<T>,T,T> implements SingleSelect<ListBox<T>,T>
List Box allows the user to select one or more values from a scrollable list of items. Although its functionally similar to Checkbox Group and Radio Button Group, List Box is designed to be used as a lightweight scrollable selection list rather than a form input field.
List Box also supports using dividers to group related items. Use them sparingly to avoid creating unnecessary visual clutter. List Box supports both single and multiple selection. The former allows the user to select only one item while the latter enables multiple items to be selected.
Items can be rendered with rich content instead of plain text. This can be useful to provide additional information in a more legible fashion than appending it to the item text.
Best Practices:
List Box is not designed to be used as an input field in forms, and lacks features like label, helper, and validation errors. List Box is best suited to be used as a lightweight, scrollable, single-column list for single or multi-selection of items.Author:
Vaadin Ltd
See Also:
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.vaadin.flow.component.AbstractField
AbstractField.ComponentValueChangeEvent<C extends Component,V>
-
Nested classes/interfaces inherited from interface com.vaadin.flow.data.binder.HasItemComponents
HasItemComponents.ItemComponent<T>
-
Nested classes/interfaces inherited from interface com.vaadin.flow.component.HasValue
HasValue.ValueChangeEvent<V>, HasValue.ValueChangeListener<E extends HasValue.ValueChangeEvent<?>>
-
-
Constructor Summary
Constructors Constructor Description ListBox()
Creates a new list box component.
-
Method Summary
All Methods Modifier and Type Method Description protected boolean
valueEquals(T value1, T value2)
Compares two value instances to each other to determine whether they are equal.
-
Methods inherited from class com.vaadin.flow.component.listbox.ListBoxBase
getDataProvider, getGenericDataView, getItemEnabledProvider, getItemId, getItemLabelGenerator, getItemRenderer, getListDataView, onAttach, onDetach, onEnabledStateChanged, setDataProvider, setItemEnabledProvider, setItemLabelGenerator, setItems, setItems, setItems, setItems, setRenderer, setRequiredIndicatorVisible
-
Methods inherited from class com.vaadin.flow.component.AbstractSinglePropertyField
getSynchronizationRegistration, hasValidValue, setPresentationValue, setSynchronizedEvent
-
Methods inherited from class com.vaadin.flow.component.AbstractField
addValueChangeListener, getEmptyValue, getValue, isEmpty, setModelValue, setValue
-
Methods inherited from class com.vaadin.flow.component.Component
addListener, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getLocale, getParent, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, scrollIntoView, set, setElement, setId, setVisible
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListener
-
Methods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListener
-
Methods inherited from interface com.vaadin.flow.component.HasComponents
add, add, addComponentAsFirst, addComponentAtIndex, remove, removeAll
-
Methods inherited from interface com.vaadin.flow.component.HasElement
getElement
-
Methods inherited from interface com.vaadin.flow.component.HasEnabled
isEnabled, setEnabled
-
Methods inherited from interface com.vaadin.flow.data.binder.HasItemComponents
addComponents, getItemPosition, prependComponents
-
Methods inherited from interface com.vaadin.flow.data.provider.HasListDataView
setItems, setItems
-
Methods inherited from interface com.vaadin.flow.component.HasSize
getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFull
-
Methods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
-
Methods inherited from interface com.vaadin.flow.component.HasValue
addValueChangeListener, clear, getEmptyValue, getOptionalValue, getValue, isEmpty, setValue
-
Methods inherited from interface com.vaadin.flow.component.HasValueAndElement
isReadOnly, isRequiredIndicatorVisible, setReadOnly, setRequiredIndicatorVisible
-
-
-
-
Method Detail
-
valueEquals
protected boolean valueEquals(T value1, T value2)
Compares two value instances to each other to determine whether they are equal. Equality is used to determine whether to update internal state and fire an event when
AbstractField.setValue(Object)
orAbstractField.setModelValue(Object, boolean)
is called. Subclasses can override this method to define an alternative comparison method instead ofObject.equals(Object)
.Overrides:
valueEquals
in classAbstractField<ListBox<T>,T>
Parameters:
value1
- the first instancevalue2
- the second instanceReturns:
true
if the instances are equal; otherwisefalse
-
-