T - the type of the items to be inserted in the combo box@HtmlImport(value="frontend://flow-component-renderer.html") public class ComboBox<T> extends GeneratedVaadinComboBox<ComboBox<T>,T> implements com.vaadin.flow.component.HasSize, com.vaadin.flow.component.HasValidation, com.vaadin.flow.data.binder.HasDataProvider<T>
vaadin-combo-box webcomponent. It
contains the same features of the webcomponent, such as item filtering,
object selection and item templating.GeneratedVaadinComboBox.CustomValueSetEvent<R extends GeneratedVaadinComboBox<R,?>>, GeneratedVaadinComboBox.FilterChangeEvent<R extends GeneratedVaadinComboBox<R,?>>, GeneratedVaadinComboBox.InvalidChangeEvent<R extends GeneratedVaadinComboBox<R,?>>, GeneratedVaadinComboBox.OpenedChangeEvent<R extends GeneratedVaadinComboBox<R,?>>, GeneratedVaadinComboBox.SelectedItemChangeEvent<R extends GeneratedVaadinComboBox<R,?>>com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<C extends com.vaadin.flow.component.Component,V>com.vaadin.flow.component.BlurNotifier.BlurEvent<C extends com.vaadin.flow.component.Component>| Constructor and Description |
|---|
ComboBox()
Default constructor.
|
ComboBox(String label)
Creates an empty combo box with the defined label.
|
ComboBox(String label,
Collection<T> items)
Creates a combo box with the defined label and populated with the items
in the collection.
|
ComboBox(String label,
T... items)
Creates a combo box with the defined label and populated with the items
in the array.
|
| Modifier and Type | Method and Description |
|---|---|
com.vaadin.flow.shared.Registration |
addCustomValueSetListener(com.vaadin.flow.component.ComponentEventListener<GeneratedVaadinComboBox.CustomValueSetEvent<ComboBox<T>>> listener)
Adds a listener for CustomValueSetEvent which is fired when user types in
a value that don't already exist in the ComboBox.
|
com.vaadin.flow.data.provider.DataProvider<T,?> |
getDataProvider() |
T |
getEmptyValue() |
String |
getErrorMessage()
Gets the current error message from the combobox.
|
List<T> |
getFilteredItems()
Gets the list of items which were filtered by the user input.
|
com.vaadin.flow.component.ItemLabelGenerator<T> |
getItemLabelGenerator()
Gets the item label generator that is used to produce the strings shown
in the combo box for each item.
|
String |
getLabel()
Gets the label of the combobox.
|
String |
getPattern()
Gets the valid input pattern
|
String |
getPlaceholder()
Gets the placeholder of the combobox.
|
T |
getValue() |
boolean |
isAllowCustomValue()
If
true, the user can input a value that is not present in the
items list. |
boolean |
isAutofocus()
Get the state for the auto-focus property of the combobox.
|
boolean |
isInvalid()
Gets the validity of the combobox output.
|
boolean |
isOpened()
Gets the states of the drop-down.
|
boolean |
isPreventInvalidInput()
Determines whether preventing the user from inputing invalid value.
|
boolean |
isRequired()
Determines whether the combobox is marked as input required.
|
void |
onEnabledStateChanged(boolean enabled) |
void |
setAllowCustomValue(boolean allowCustomValue)
Description copied from corresponding location in WebComponent:
|
void |
setAutofocus(boolean autofocus)
Set the combobox to be input focused when the page loads.
|
void |
setDataProvider(com.vaadin.flow.data.provider.DataProvider<T,?> dataProvider) |
void |
setErrorMessage(String errorMessage)
Description copied from corresponding location in WebComponent:
|
void |
setFilteredItems(Collection<T> filteredItems)
It sets the list of visible items in reaction of the input of the user.
|
void |
setFilteredItems(T... filteredItems)
Convenience method for the
setFilteredItems(Collection). |
void |
setInvalid(boolean invalid)
Description copied from corresponding location in WebComponent:
|
void |
setItemLabelGenerator(com.vaadin.flow.component.ItemLabelGenerator<T> itemLabelGenerator)
Sets the item label generator that is used to produce the strings shown
in the combo box for each item.
|
void |
setLabel(String label)
Description copied from corresponding location in WebComponent:
|
void |
setOpened(boolean opened)
Description copied from corresponding location in WebComponent:
|
void |
setPattern(String pattern)
Description copied from corresponding location in WebComponent:
|
void |
setPlaceholder(String placeholder)
Description copied from corresponding location in WebComponent:
|
void |
setPreventInvalidInput(boolean preventInvalidInput)
Description copied from corresponding location in WebComponent:
|
void |
setRenderer(com.vaadin.flow.data.renderer.Renderer<T> renderer)
Sets the TemplateRenderer responsible to render the individual items in
the list of possible choices of the ComboBox.
|
void |
setRequired(boolean required)
Description copied from corresponding location in WebComponent:
|
void |
setValue(T value) |
addFilterChangeListener, addInvalidChangeListener, addOpenedChangeListener, addSelectedItemChangeListener, addToPrefix, cancel, checkValidity, close, getErrorMessageString, getFilteredItemsJsonArray, getFilterString, getItemsJsonArray, getLabelString, getNameString, getPatternString, getPlaceholderString, isAllowCustomValueBoolean, isAutofocusBoolean, isDisabledBoolean, isInvalidBoolean, isLoadingBoolean, isOpenedBoolean, isPreventInvalidInputBoolean, isReadonlyBoolean, isRequiredBoolean, open, remove, removeAll, setDisabled, setFilter, setFilteredItems, setItems, setLoading, setName, setReadonly, validatehasValidValue, setPresentationValue, setSynchronizedEventaddValueChangeListener, isEmpty, setModelValue, valueEqualsaddListener, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getLocale, getParent, getTranslation, getTranslation, getUI, hasListener, isTemplateMapped, isVisible, onAttach, onDetach, set, setElement, setId, setVisibleclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetHeight, getWidth, setHeight, setSizeFull, setSizeUndefined, setWidthaddClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassNameblur, focus, getTabIndex, setTabIndexpublic ComboBox()
public ComboBox(String label)
label - the label describing the combo boxpublic ComboBox(String label, Collection<T> items)
label - the label describing the combo boxitems - the items to be shown in the list of the combo boxHasDataProvider.setItems(Collection)@SafeVarargs public ComboBox(String label, T... items)
label - the label describing the combo boxitems - the items to be shown in the list of the combo boxHasItems.setItems(Object...)public void setRenderer(com.vaadin.flow.data.renderer.Renderer<T> renderer)
setItemLabelGenerator(ItemLabelGenerator).renderer - a renderer for the items in the selection list of the
ComboBox, not nullpublic void setDataProvider(com.vaadin.flow.data.provider.DataProvider<T,?> dataProvider)
setDataProvider in interface com.vaadin.flow.data.binder.HasDataProvider<T>public com.vaadin.flow.data.provider.DataProvider<T,?> getDataProvider()
public List<T> getFilteredItems()
public void setFilteredItems(T... filteredItems)
setFilteredItems(Collection). It sets
the list of visible items in reaction of the input of the user.filteredItems - the items to show in response of a filter inputpublic void setFilteredItems(Collection<T> filteredItems)
filteredItems - the items to show in response of a filter inputpublic void setItemLabelGenerator(com.vaadin.flow.component.ItemLabelGenerator<T> itemLabelGenerator)
String.valueOf(Object) is used.
When the setRenderer(Renderer) is used, the ItemLabelGenerator
is only used to show the selected item label.
itemLabelGenerator - the item label provider to use, not nullpublic com.vaadin.flow.component.ItemLabelGenerator<T> getItemLabelGenerator()
public void setOpened(boolean opened)
GeneratedVaadinComboBoxDescription copied from corresponding location in WebComponent:
True if the dropdown is open, false otherwise.
setOpened in class GeneratedVaadinComboBox<ComboBox<T>,T>opened - the boolean value to setpublic boolean isOpened()
true if the drop-down is opened, false otherwisepublic void setInvalid(boolean invalid)
GeneratedVaadinComboBoxDescription copied from corresponding location in WebComponent:
Set to true if the value is invalid.
setInvalid in interface com.vaadin.flow.component.HasValidationsetInvalid in class GeneratedVaadinComboBox<ComboBox<T>,T>invalid - the boolean value to setpublic boolean isInvalid()
return true, if the value is invalid.
isInvalid in interface com.vaadin.flow.component.HasValidationvalidity property from the componentpublic void setErrorMessage(String errorMessage)
GeneratedVaadinComboBoxDescription copied from corresponding location in WebComponent:
The error message to display when the input is invalid.
setErrorMessage in interface com.vaadin.flow.component.HasValidationsetErrorMessage in class GeneratedVaadinComboBox<ComboBox<T>,T>errorMessage - the String value to setpublic String getErrorMessage()
getErrorMessage in interface com.vaadin.flow.component.HasValidationpublic void setAllowCustomValue(boolean allowCustomValue)
GeneratedVaadinComboBoxDescription copied from corresponding location in WebComponent:
If true, the user can input a value that is not present in the
items list. value property will be set to the input value in this
case. Also, when value is set programmatically, the input value
will be set to reflect that value.
setAllowCustomValue in class GeneratedVaadinComboBox<ComboBox<T>,T>allowCustomValue - the boolean value to setpublic boolean isAllowCustomValue()
true, the user can input a value that is not present in the
items list. value property will be set to the input value in this
case. Also, when value is set programmatically, the input value
will be set to reflect that value.
This property is not synchronized automatically from the client side, so the returned value may not be the same as in client side.
allowCustomValue property from the comboboxpublic void setAutofocus(boolean autofocus)
setAutofocus in class GeneratedVaadinComboBox<ComboBox<T>,T>autofocus - the boolean value to setpublic boolean isAutofocus()
This property is not synchronized automatically from the client side, so the returned value may not be the same as in client side.
autofocus property from the comboboxpublic void setPreventInvalidInput(boolean preventInvalidInput)
GeneratedVaadinComboBoxDescription copied from corresponding location in WebComponent:
Set to true to prevent the user from entering invalid input.
setPreventInvalidInput in class GeneratedVaadinComboBox<ComboBox<T>,T>preventInvalidInput - the boolean value to setpublic boolean isPreventInvalidInput()
This property is not synchronized automatically from the client side, so the returned value may not be the same as in client side.
preventInvalidInput property of the comboboxpublic void setRequired(boolean required)
GeneratedVaadinComboBoxDescription copied from corresponding location in WebComponent:
Set to true to mark the input as required.
setRequired in class GeneratedVaadinComboBox<ComboBox<T>,T>required - the boolean value to setpublic boolean isRequired()
This property is not synchronized automatically from the client side, so the returned value may not be the same as in client side.
true if the input is required, false otherwisepublic void setLabel(String label)
GeneratedVaadinComboBoxDescription copied from corresponding location in WebComponent:
The label for this element.
setLabel in class GeneratedVaadinComboBox<ComboBox<T>,T>label - the String value to setpublic String getLabel()
label property of the comboboxpublic void setPlaceholder(String placeholder)
GeneratedVaadinComboBoxDescription copied from corresponding location in WebComponent:
A placeholder string in addition to the label.
setPlaceholder in class GeneratedVaadinComboBox<ComboBox<T>,T>placeholder - the String value to setpublic String getPlaceholder()
placeholder property of the comboboxpublic void setPattern(String pattern)
GeneratedVaadinComboBoxDescription copied from corresponding location in WebComponent:
A pattern to validate the input with.
setPattern in class GeneratedVaadinComboBox<ComboBox<T>,T>pattern - the String value to setpublic String getPattern()
pattern property of the comboboxpublic T getEmptyValue()
public void setValue(T value)
public T getValue()
public com.vaadin.flow.shared.Registration addCustomValueSetListener(com.vaadin.flow.component.ComponentEventListener<GeneratedVaadinComboBox.CustomValueSetEvent<ComboBox<T>>> listener)
As a side effect makes the ComboBox allow custom values. If you don't
want to allow a user to add new values to the list once the listener is
added please disable it explicitly via the
setAllowCustomValue(boolean) method.
The custom value becomes disallowed automatically once the last custom value set listener is removed.
addCustomValueSetListener in class GeneratedVaadinComboBox<ComboBox<T>,T>listener - the listener to be notified when a new value is filledRegistration for removing the event listenersetAllowCustomValue(boolean)public void onEnabledStateChanged(boolean enabled)
onEnabledStateChanged in class com.vaadin.flow.component.ComponentCopyright © 2018. All rights reserved.