public class ComboBox extends AbstractSelect implements AbstractSelect.Filtering, FieldEvents.BlurNotifier, FieldEvents.FocusNotifier
| Modifier and Type | Class and Description |
|---|---|
static interface |
ComboBox.ItemStyleGenerator
ItemStyleGenerator can be used to add custom styles to combo box items
shown in the popup.
|
AbstractSelect.AbstractSelectTargetDetails, AbstractSelect.AcceptItem, AbstractSelect.CaptionChangeListener, AbstractSelect.DefaultNewItemHandler, AbstractSelect.Filtering, AbstractSelect.ItemCaptionMode, AbstractSelect.ItemDescriptionGenerator, AbstractSelect.NewItemHandler, AbstractSelect.TargetItemIs, AbstractSelect.VerticalLocationIsAbstractField.FocusShortcut, AbstractField.ReadOnlyStatusChangeEventContainer.Editor, Container.Filter, Container.Filterable, Container.Hierarchical, Container.Indexed, Container.ItemSetChangeListener, Container.ItemSetChangeNotifier, Container.Ordered, Container.PropertySetChangeListener, Container.PropertySetChangeNotifier, Container.SimpleFilterable, Container.Sortable, Container.ViewerComponent.ErrorEvent, Component.Event, Component.Focusable, Component.ListenerClientConnector.AttachEvent, ClientConnector.AttachListener, ClientConnector.ConnectorErrorEvent, ClientConnector.DetachEvent, ClientConnector.DetachListenerSizeable.UnitField.ValueChangeEventBuffered.SourceExceptionProperty.Editor, Property.ReadOnlyException, Property.ReadOnlyStatusChangeListener, Property.ReadOnlyStatusChangeNotifier, Property.Transactional<T>, Property.ValueChangeListener, Property.ValueChangeNotifier, Property.Viewer| Modifier and Type | Field and Description |
|---|---|
protected int |
pageLength
Holds value of property pageLength.
|
ITEM_CAPTION_MODE_EXPLICIT, ITEM_CAPTION_MODE_EXPLICIT_DEFAULTS_ID, ITEM_CAPTION_MODE_ICON_ONLY, ITEM_CAPTION_MODE_ID, ITEM_CAPTION_MODE_INDEX, ITEM_CAPTION_MODE_ITEM, ITEM_CAPTION_MODE_PROPERTY, itemIdMapper, itemsDESIGN_ATTR_PLAIN_TEXTFILTERINGMODE_CONTAINS, FILTERINGMODE_OFF, FILTERINGMODE_STARTSWITHSIZE_UNDEFINED, UNITS_CM, UNITS_EM, UNITS_EX, UNITS_INCH, UNITS_MM, UNITS_PERCENTAGE, UNITS_PICAS, UNITS_PIXELS, UNITS_POINTS| Constructor and Description |
|---|
ComboBox() |
ComboBox(String caption) |
ComboBox(String caption,
Collection<?> options) |
ComboBox(String caption,
Container dataSource) |
| Modifier and Type | Method and Description |
|---|---|
void |
addBlurListener(FieldEvents.BlurListener listener)
Adds a
BlurListener to the Component which gets fired
when a Field loses keyboard focus. |
void |
addFocusListener(FieldEvents.FocusListener listener)
Adds a
FocusListener to the Component which gets fired
when a Field receives keyboard focus. |
void |
addListener(FieldEvents.BlurListener listener)
Deprecated.
As of 7.0, replaced by
#addBlurListener(BlurListener) |
void |
addListener(FieldEvents.FocusListener listener)
Deprecated.
As of 7.0, replaced by
#addFocusListener(FocusListener) |
protected Container.Filter |
buildFilter(String filterString,
FilteringMode filteringMode)
Constructs a filter instance to use when using a Filterable container in
the
ITEM_CAPTION_MODE_PROPERTY mode. |
void |
changeVariables(Object source,
Map<String,Object> variables)
Invoked when the value of a variable has changed.
|
void |
containerItemSetChange(Container.ItemSetChangeEvent event)
Lets the listener know a Containers Item set has changed.
|
protected List<?> |
getFilteredOptions()
Filters the options in memory and returns the full filtered list.
|
FilteringMode |
getFilteringMode()
Gets the current filtering mode.
|
String |
getInputPrompt()
Gets the current input prompt.
|
ComboBox.ItemStyleGenerator |
getItemStyleGenerator()
Gets the currently used item style generator.
|
protected List<?> |
getOptionsWithFilter(boolean needNullSelectOption)
Returns the filtered options for the current page using a container
filter.
|
int |
getPageLength()
Returns the page length of the suggestion popup.
|
String |
getPopupWidth()
Returns the suggestion pop-up's width as a CSS string.
|
protected ComboBoxState |
getState()
Returns the shared state bean with information to be sent from the server
to the client.
|
boolean |
isMultiSelect()
Deprecated.
As of 7.0, use
ListSelect, OptionGroup or
TwinColSelect instead |
boolean |
isScrollToSelectedItem()
Returns true if the select should find the page with the selected item
when opening the popup (single select combo box only).
|
boolean |
isTextInputAllowed()
Returns true if the user can enter text into the field to either filter
the selections or enter a new value if
AbstractSelect.isNewItemsAllowed()
returns true. |
void |
paintContent(PaintTarget target)
Paints the content of this component.
|
void |
removeBlurListener(FieldEvents.BlurListener listener)
Removes a
BlurListener from the Component. |
void |
removeFocusListener(FieldEvents.FocusListener listener)
Removes a
FocusListener from the Component. |
void |
removeListener(FieldEvents.BlurListener listener)
Deprecated.
As of 7.0, replaced by
#removeBlurListener(BlurListener) |
void |
removeListener(FieldEvents.FocusListener listener)
Deprecated.
As of 7.0, replaced by
#removeFocusListener(FocusListener) |
void |
setFilteringMode(FilteringMode filteringMode)
Sets the option filtering mode.
|
void |
setInputPrompt(String inputPrompt)
Sets the input prompt - a textual prompt that is displayed when the
select would otherwise be empty, to prompt the user for input.
|
void |
setItemStyleGenerator(ComboBox.ItemStyleGenerator itemStyleGenerator)
Sets the item style generator that is used to produce custom styles for
showing items in the popup.
|
void |
setMultiSelect(boolean multiSelect)
Deprecated.
As of 7.0, use
ListSelect, OptionGroup or
TwinColSelect instead |
void |
setPageLength(int pageLength)
Sets the page length for the suggestion popup.
|
void |
setPopupWidth(String width)
Sets the suggestion pop-up's width as a CSS string.
|
void |
setScrollToSelectedItem(boolean scrollToSelectedItem)
Sets whether to scroll the selected item visible (directly open the page
on which it is) when opening the combo box popup or not.
|
void |
setTextInputAllowed(boolean textInputAllowed)
Sets whether it is possible to input text into the field or whether the
field area of the component is just used to show what is selected.
|
addContainerProperty, addItem, addItem, addItems, addItems, addItemSetChangeListener, addListener, addListener, addPropertySetChangeListener, attach, containerPropertySetChange, containsId, detach, fireItemSetChange, firePropertySetChange, getCaptionChangeListener, getContainerDataSource, getContainerProperty, getContainerPropertyIds, getItem, getItemCaption, getItemCaptionMode, getItemCaptionPropertyId, getItemIcon, getItemIconPropertyId, getItemIds, getListeners, getNewItemHandler, getNullSelectionItemId, getType, getType, getValue, getVisibleItemIds, isEmpty, isNewItemsAllowed, isNullSelectionAllowed, isSelected, paintItem, readDesign, readItem, readItems, removeAllItems, removeContainerProperty, removeItem, removeItemSetChangeListener, removeListener, removeListener, removePropertySetChangeListener, sanitizeSelection, select, setContainerDataSource, setItemCaption, setItemCaptionMode, setItemCaptionPropertyId, setItemIcon, setItemIconPropertyId, setNewItemHandler, setNewItemsAllowed, setNullSelectionAllowed, setNullSelectionItemId, setValue, setValue, size, unselect, writeDesign, writeItem, writeItemsaddListener, addListener, addReadOnlyStatusChangeListener, addValidator, addValueChangeListener, beforeClientResponse, clear, commit, discard, fireReadOnlyStatusChange, fireValueChange, focus, getConversionError, getConversionError, getConvertedValue, getConverter, getCurrentBufferedSourceException, getCustomAttributes, getErrorMessage, getInternalValue, getModelType, getPropertyDataSource, getRequiredError, getState, getTabIndex, getValidators, isBuffered, isImmediate, isInvalidAllowed, isInvalidCommitted, isModified, isReadOnly, isRequired, isValid, isValidationVisible, readOnlyStatusChange, removeAllValidators, removeListener, removeListener, removeReadOnlyStatusChangeListener, removeValidator, removeValueChangeListener, setBuffered, setConversionError, setConvertedValue, setConverter, setConverter, setCurrentBufferedSourceException, setInternalValue, setInvalidAllowed, setInvalidCommitted, setLocale, setPropertyDataSource, setReadOnly, setRequired, setRequiredError, setTabIndex, setValidationVisible, setValue, shouldHideErrors, toString, validate, validate, valueChangeaddContextClickListener, addListener, addShortcutListener, addStyleName, findAncestor, fireComponentErrorEvent, fireComponentEvent, getActionManager, getCaption, getComponentError, getData, getDebugId, getDescription, getExplicitImmediateValue, getHeight, getHeightUnits, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getWidth, getWidthUnits, isCaptionAsHtml, isConnectorEnabled, isEnabled, isOrHasAncestor, isResponsive, isVisible, removeContextClickListener, removeListener, removeShortcutListener, removeStyleName, setCaption, setCaptionAsHtml, setComponentError, setData, setDebugId, setDescription, setEnabled, setHeight, setHeight, setHeightUndefined, setIcon, setId, setImmediate, setParent, setPrimaryStyleName, setResponsive, setSizeFull, setSizeUndefined, setStyleName, setStyleName, setVisible, setWidth, setWidth, setWidthUndefinedaddAttachListener, addDetachListener, addExtension, addListener, addListener, addListener, addMethodInvocationToQueue, createState, encodeState, equals, fireEvent, getAllChildrenIterable, getConnectorId, getErrorHandler, getExtensions, getResource, getRpcManager, getRpcProxy, getSession, getStateType, getUI, handleConnectorRequest, hashCode, hasListeners, isAttached, isThis, markAsDirty, markAsDirtyRecursive, registerRpc, registerRpc, removeAttachListener, removeDetachListener, removeExtension, removeListener, removeListener, removeListener, removeListener, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler, setResourceclone, finalize, getClass, notify, notifyAll, wait, wait, waitmarkAsDirtyisEnabled, isImmediateaddListener, addStyleName, getCaption, getDescription, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getUI, isEnabled, isReadOnly, isVisible, removeListener, removeStyleName, setCaption, setEnabled, setIcon, setId, setParent, setPrimaryStyleName, setReadOnly, setStyleName, setVisibleaddAttachListener, addDetachListener, beforeClientResponse, encodeState, getErrorHandler, getExtensions, getRpcManager, getStateType, handleConnectorRequest, isAttached, isConnectorEnabled, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandlergetConnectorIdgetHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeight, setHeightUndefined, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthUndefinedaddShortcutListener, removeShortcutListenerprotected int pageLength
public ComboBox()
public ComboBox(String caption, Collection<?> options)
public ComboBox(String caption)
public String getInputPrompt()
setInputPrompt(String)public void setInputPrompt(String inputPrompt)
inputPrompt - the desired input prompt, or null to disablepublic void paintContent(PaintTarget target) throws PaintException
AbstractSelectpaintContent in interface LegacyComponentpaintContent in class AbstractSelecttarget - the Paint Event.PaintException - if the paint operation failed.public void setTextInputAllowed(boolean textInputAllowed)
NativeSelecttextInputAllowed - true to allow entering text, false to just show the current
selectionisTextInputAllowed()public boolean isTextInputAllowed()
AbstractSelect.isNewItemsAllowed()
returns true. If text input is disabled, the comboBox will work in the
same way as a NativeSelectprotected ComboBoxState getState()
AbstractComponentgetState in class AbstractSelectprotected List<?> getOptionsWithFilter(boolean needNullSelectOption)
filteredSize is set to the total number of
items passing the filter.
The current container must be Filterable and Indexed, and
the filtering mode must be suitable for container filtering (tested with
#canUseContainerFilter()).
Use getFilteredOptions() and
sanitizeList(List, boolean) if this is not the case.needNullSelectOption - protected Container.Filter buildFilter(String filterString, FilteringMode filteringMode)
ITEM_CAPTION_MODE_PROPERTY mode.
Note that the client side implementation expects the filter string to
apply to the item caption string it sees, so changing the behavior of
this method can cause problems.filterString - filteringMode - public void containerItemSetChange(Container.ItemSetChangeEvent event)
AbstractSelectcontainerItemSetChange in interface Container.ItemSetChangeListenercontainerItemSetChange in class AbstractSelectevent - change event textContainer.ItemSetChangeListener#containerItemSetChange(Container.ItemSetChangeEvent)protected List<?> getFilteredOptions()
getOptionsWithFilter(boolean) if possible (filterable container
and suitable item caption mode etc.).public void changeVariables(Object source, Map<String,Object> variables)
changeVariables in interface VariableOwnerchangeVariables in class AbstractSelectsource - the Source of the variable change. This is the origin of the
event. For example in Web Adapter this is the request.variables - the Mapping from variable names to new variable values.com.vaadin.ui.AbstractComponent#changeVariables(java.lang.Object,
java.util.Map)public void setFilteringMode(FilteringMode filteringMode)
AbstractSelect.FilteringsetFilteringMode in interface AbstractSelect.FilteringfilteringMode - the filtering mode to usepublic FilteringMode getFilteringMode()
AbstractSelect.FilteringgetFilteringMode in interface AbstractSelect.Filteringpublic void addBlurListener(FieldEvents.BlurListener listener)
FieldEvents.BlurNotifierBlurListener to the Component which gets fired
when a Field loses keyboard focus.addBlurListener in interface FieldEvents.BlurNotifierFieldEvents.BlurListener@Deprecated public void addListener(FieldEvents.BlurListener listener)
#addBlurListener(BlurListener)addListener in interface FieldEvents.BlurNotifierpublic void removeBlurListener(FieldEvents.BlurListener listener)
FieldEvents.BlurNotifierBlurListener from the Component.removeBlurListener in interface FieldEvents.BlurNotifierFieldEvents.BlurListener@Deprecated public void removeListener(FieldEvents.BlurListener listener)
#removeBlurListener(BlurListener)removeListener in interface FieldEvents.BlurNotifierpublic void addFocusListener(FieldEvents.FocusListener listener)
FieldEvents.FocusNotifierFocusListener to the Component which gets fired
when a Field receives keyboard focus.addFocusListener in interface FieldEvents.FocusNotifierFieldEvents.FocusListener@Deprecated public void addListener(FieldEvents.FocusListener listener)
#addFocusListener(FocusListener)addListener in interface FieldEvents.FocusNotifierpublic void removeFocusListener(FieldEvents.FocusListener listener)
FieldEvents.FocusNotifierFocusListener from the Component.removeFocusListener in interface FieldEvents.FocusNotifierFieldEvents.FocusListener@Deprecated public void removeListener(FieldEvents.FocusListener listener)
#removeFocusListener(FocusListener)removeListener in interface FieldEvents.FocusNotifier@Deprecated public void setMultiSelect(boolean multiSelect)
ListSelect, OptionGroup or
TwinColSelect insteadsetMultiSelect in class AbstractSelectmultiSelect - the New value of property multiSelect.UnsupportedOperationException - if trying to activate multiselect modeAbstractSelect.setMultiSelect(boolean)@Deprecated public boolean isMultiSelect()
ListSelect, OptionGroup or
TwinColSelect insteadisMultiSelect in class AbstractSelectAbstractSelect.isMultiSelect()public int getPageLength()
public String getPopupWidth()
setPopupWidth(java.lang.String)public void setPageLength(int pageLength)
pageLength - the pageLength to setpublic void setPopupWidth(String width)
width - the widthgetPopupWidth()public void setScrollToSelectedItem(boolean scrollToSelectedItem)
scrollToSelectedItem - true to find the page with the selected item when opening the
selection popuppublic boolean isScrollToSelectedItem()
setScrollToSelectedItem(boolean)public void setItemStyleGenerator(ComboBox.ItemStyleGenerator itemStyleGenerator)
itemStyleGenerator - the item style generator to set, or null to not
use any custom item stylespublic ComboBox.ItemStyleGenerator getItemStyleGenerator()
null if no generator is usedCopyright © 2022 Vaadin Ltd. All rights reserved.