com.vaadin.flow.component.listbox.
Class ListBoxBase<C extends ListBoxBase<C,ITEM,VALUE>,ITEM,VALUE>
- 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<C,ITEM,VALUE>
-
All Implemented Interfaces:
AttachNotifier
,DetachNotifier
,HasComponents
,HasElement
,HasEnabled
,HasSize
,HasStyle
,HasValue<AbstractField.ComponentValueChangeEvent<C,VALUE>,VALUE>
,HasValueAndElement<AbstractField.ComponentValueChangeEvent<C,VALUE>,VALUE>
,HasItemComponents<ITEM>
,HasDataView<ITEM,Void,ListBoxDataView<ITEM>>
,HasListDataView<ITEM,ListBoxListDataView<ITEM>>
,Serializable
Direct Known Subclasses:
@Tag("vaadin-list-box") @NpmPackage(value="@vaadin/polymer-legacy-adapter",version="23.1.15") @NpmPackage(value="@vaadin/list-box",version="23.1.15") @NpmPackage(value="@vaadin/vaadin-list-box",version="23.1.15") @JsModule("@vaadin/polymer-legacy-adapter/style-modules.js") @JsModule("@vaadin/list-box/src/vaadin-list-box.js") public abstract class ListBoxBase<C extends ListBoxBase<C,ITEM,VALUE>,ITEM,VALUE> extends AbstractSinglePropertyField<C,VALUE> implements HasItemComponents<ITEM>, HasSize, HasListDataView<ITEM,ListBoxListDataView<ITEM>>, HasDataView<ITEM,Void,ListBoxDataView<ITEM>>, HasStyle
Base class for the
ListBox
andMultiSelectListBox
.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<?>>
-
-
Method Summary
All Methods Modifier and Type Method Description DataProvider<ITEM,?>
getDataProvider()
Deprecated.
usegetListDataView()
orgetGenericDataView()
insteadListBoxDataView<ITEM>
getGenericDataView()
Gets the generic data view for the ListBox.
SerializablePredicate<ITEM>
getItemEnabledProvider()
Returns the item enabled predicate.
protected Object
getItemId(ITEM item)
ItemLabelGenerator<ITEM>
getItemLabelGenerator()
Gets the item label generator that is used to produce the strings shown in the ListBox for each item.
ComponentRenderer<? extends Component,ITEM>
getItemRenderer()
Returns the item component renderer.
ListBoxListDataView<ITEM>
getListDataView()
Gets the list data view for the ListBox.
protected void
onAttach(AttachEvent attachEvent)
Called when the component is attached to a UI.
protected void
onDetach(DetachEvent detachEvent)
Called when the component is detached from a UI.
void
onEnabledStateChanged(boolean enabled)
Handle component enable state when the enabled state changes.
void
setDataProvider(DataProvider<ITEM,?> dataProvider)
Deprecated.
use instead one of thesetItems
methods which provide access to eitherListBoxListDataView
orListBoxDataView
void
setItemEnabledProvider(SerializablePredicate<ITEM> itemEnabledProvider)
Sets the item enabled predicate for this ListBox.
void
setItemLabelGenerator(ItemLabelGenerator<ITEM> itemLabelGenerator)
Sets the item label generator that is used to produce the strings shown in the ListBox for each item.
ListBoxDataView<ITEM>
setItems(DataProvider<ITEM,Void> dataProvider)
Set a generic data provider for the ListBox to use and returns the base
ListBoxDataView
that provides API to get information on the items.ListBoxDataView<ITEM>
setItems(InMemoryDataProvider<ITEM> inMemoryDataProvider)
Sets an in-memory data provider for the ListBox to use
ListBoxListDataView<ITEM>
setItems(ListDataProvider<ITEM> listDataProvider)
Sets a ListDataProvider for the ListBox to use and returns a
ListDataView
that provides information and allows operations on the items.void
setItems(Stream<ITEM> streamOfItems)
Deprecated.
Because the stream is collected to a list anyway, useHasListDataView.setItems(Collection)
instead.void
setRenderer(ComponentRenderer<? extends Component,ITEM> itemRenderer)
Sets the item renderer for this ListBox.
void
setRequiredIndicatorVisible(boolean requiredIndicatorVisible)
Not supported!
-
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, valueEquals
-
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
clear, getOptionalValue
-
Methods inherited from interface com.vaadin.flow.component.HasValueAndElement
isReadOnly, isRequiredIndicatorVisible, setReadOnly
-
-
-
-
Method Detail
-
setDataProvider
@Deprecated public void setDataProvider(DataProvider<ITEM,?> dataProvider)
Deprecated.use instead one of thesetItems
methods which provide access to eitherListBoxListDataView
orListBoxDataView
-
onAttach
protected void onAttach(AttachEvent attachEvent)
Description copied from class:
Component
Called when the component is attached to a UI.
The default implementation does nothing.
This method is invoked before the
AttachEvent
is fired for the component.
-
onDetach
protected void onDetach(DetachEvent detachEvent)
Description copied from class:
Component
Called when the component is detached from a UI.
The default implementation does nothing.
This method is invoked before the
DetachEvent
is fired for the component.
-
getDataProvider
@Deprecated public DataProvider<ITEM,?> getDataProvider()
Deprecated.usegetListDataView()
orgetGenericDataView()
insteadGets the data provider.
Returns:
the data provider, not
null
-
getItemRenderer
public ComponentRenderer<? extends Component,ITEM> getItemRenderer()
Returns the item component renderer.
Returns:
the item renderer
See Also:
-
setRenderer
public void setRenderer(ComponentRenderer<? extends Component,ITEM> itemRenderer)
Sets the item renderer for this ListBox. The renderer is applied to each item to create a component which represents the item.
Parameters:
itemRenderer
- the item renderer, notnull
-
setItemLabelGenerator
public void setItemLabelGenerator(ItemLabelGenerator<ITEM> itemLabelGenerator)
Sets the item label generator that is used to produce the strings shown in the ListBox for each item. By default,
String.valueOf(Object)
is used.Parameters:
itemLabelGenerator
- the item label provider to use, not null
-
getItemLabelGenerator
public ItemLabelGenerator<ITEM> getItemLabelGenerator()
Gets the item label generator that is used to produce the strings shown in the ListBox for each item.
Returns:
the item label generator used, not null
-
setItemEnabledProvider
public void setItemEnabledProvider(SerializablePredicate<ITEM> itemEnabledProvider)
Sets the item enabled predicate for this ListBox. The predicate is applied to each item to determine whether the item should be enabled (
true
) or disabled (false
). Disabled items are displayed as grayed out and the user cannot select them. The default predicate always returns true (all the items are enabled).Parameters:
itemEnabledProvider
- the item enable predicate, notnull
-
getItemEnabledProvider
public SerializablePredicate<ITEM> getItemEnabledProvider()
Returns the item enabled predicate.
Returns:
the item enabled predicate
See Also:
setItemEnabledProvider(com.vaadin.flow.function.SerializablePredicate<ITEM>)
-
setRequiredIndicatorVisible
public void setRequiredIndicatorVisible(boolean requiredIndicatorVisible)
Not supported!
Not supported by the client-side web-component, see issue in GitHub.
Specified by:
setRequiredIndicatorVisible
in interfaceHasValue<C extends ListBoxBase<C,ITEM,VALUE>,ITEM>
Specified by:
setRequiredIndicatorVisible
in interfaceHasValueAndElement<C extends ListBoxBase<C,ITEM,VALUE>,ITEM>
Parameters:
requiredIndicatorVisible
-true
to make the required indicator visible,false
if notThrows:
-
onEnabledStateChanged
public void onEnabledStateChanged(boolean enabled)
Description copied from class:
Component
Handle component enable state when the enabled state changes.
By default this sets or removes the 'disabled' attribute from the element. This can be overridden to have custom handling.
Overrides:
onEnabledStateChanged
in classComponent
Parameters:
enabled
- the new enabled state of the component
-
setItems
public ListBoxDataView<ITEM> setItems(DataProvider<ITEM,Void> dataProvider)
Set a generic data provider for the ListBox to use and returns the base
ListBoxDataView
that provides API to get information on the items.This method should be used only when the data provider type is not either
ListDataProvider
orBackEndDataProvider
.Specified by:
setItems
in interfaceHasDataView<C extends ListBoxBase<C,ITEM,VALUE>,ITEM,VALUE>
Parameters:
dataProvider
- DataProvider instance to use, notnull
Returns:
ListBoxDataView providing information on the data
-
setItems
public ListBoxDataView<ITEM> setItems(InMemoryDataProvider<ITEM> inMemoryDataProvider)
Sets an in-memory data provider for the ListBox to use
Note! Using a
ListDataProvider
instead of aInMemoryDataProvider
is recommended to get access toListBoxListDataView
API by usingHasListDataView.setItems(ListDataProvider)
.Specified by:
setItems
in interfaceHasDataView<C extends ListBoxBase<C,ITEM,VALUE>,ITEM,VALUE>
Parameters:
inMemoryDataProvider
- InMemoryDataProvider to use, notnull
Returns:
ListBoxDataView providing information on the data
-
setItems
public ListBoxListDataView<ITEM> setItems(ListDataProvider<ITEM> listDataProvider)
Sets a ListDataProvider for the ListBox to use and returns a
ListDataView
that provides information and allows operations on the items.Specified by:
setItems
in interfaceHasListDataView<C extends ListBoxBase<C,ITEM,VALUE>,ITEM>
Parameters:
listDataProvider
- ListDataProvider providing items to the ListBox.Returns:
ListBoxListDataView providing access to the items
-
setItems
@Deprecated public void setItems(Stream<ITEM> streamOfItems)
Deprecated.Because the stream is collected to a list anyway, useHasListDataView.setItems(Collection)
instead.
-
getListDataView
public ListBoxListDataView<ITEM> getListDataView()
Gets the list data view for the ListBox. This data view should only be used when the items are in-memory and set with:
If the items are not in-memory an exception is thrown.Specified by:
getListDataView
in interfaceHasListDataView<C extends ListBoxBase<C,ITEM,VALUE>,ITEM>
Returns:
the list data view that provides access to the data bound to the ListBox
-
getGenericDataView
public ListBoxDataView<ITEM> getGenericDataView()
Gets the generic data view for the ListBox. This data view should only be used when
getListDataView()
is not applicable for the underlying data provider.Specified by:
getGenericDataView
in interfaceHasDataView<C extends ListBoxBase<C,ITEM,VALUE>,ITEM,VALUE>
Returns:
the generic DataView instance implementing
ListBoxDataView
-
-