Class FComboBox

java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.AbstractField<com.vaadin.flow.component.combobox.ComboBox<Object>,Object>
com.vaadin.flow.component.AbstractSinglePropertyField<com.vaadin.flow.component.combobox.ComboBox<Object>,Object>
com.vaadin.flow.component.combobox.ComboBoxBase<com.vaadin.flow.component.combobox.ComboBox<Object>,Object,Object>
com.vaadin.flow.component.combobox.ComboBox<Object>
com.vaadin.featurepack.ui.FComboBox
All Implemented Interfaces:
Buffered, BufferedValidatable, Container, Container.ItemSetChangeListener, Container.ItemSetChangeNotifier, Container.PropertySetChangeListener, Container.PropertySetChangeNotifier, Container.Viewer, Property<Object>, Property.Editor, Property.ReadOnlyStatusChangeListener, Property.ReadOnlyStatusChangeNotifier, Property.ValueChangeListener, Property.ValueChangeNotifier, Property.Viewer, Field<Object>, Select, Validatable, FieldEvents.BlurNotifier, FieldEvents.FocusNotifier, ClientConnector, FAbstractClientConnector, FSizeable, HasSizeable, FAbstractComponent, com.vaadin.flow.component.AttachNotifier, com.vaadin.flow.component.BlurNotifier<com.vaadin.flow.component.combobox.ComboBox<Object>>, com.vaadin.flow.component.DetachNotifier, com.vaadin.flow.component.Focusable<com.vaadin.flow.component.combobox.ComboBox<Object>>, com.vaadin.flow.component.FocusNotifier<com.vaadin.flow.component.combobox.ComboBox<Object>>, com.vaadin.flow.component.HasAriaDescription, com.vaadin.flow.component.HasAriaLabel, com.vaadin.flow.component.HasElement, com.vaadin.flow.component.HasEnabled, com.vaadin.flow.component.HasHelper, com.vaadin.flow.component.HasLabel, com.vaadin.flow.component.HasPlaceholder, com.vaadin.flow.component.HasSize, com.vaadin.flow.component.HasStyle, com.vaadin.flow.component.HasTheme, com.vaadin.flow.component.HasValidation, com.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.combobox.ComboBox<Object>,Object>,Object>, com.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.combobox.ComboBox<Object>,Object>,Object>, com.vaadin.flow.component.shared.HasAllowedCharPattern, com.vaadin.flow.component.shared.HasAutoOpen, com.vaadin.flow.component.shared.HasClearButton, com.vaadin.flow.component.shared.HasPrefix, com.vaadin.flow.component.shared.HasThemeVariant<com.vaadin.flow.component.combobox.ComboBoxVariant>, com.vaadin.flow.component.shared.HasTooltip, com.vaadin.flow.component.shared.HasValidationProperties, com.vaadin.flow.component.shared.InputField<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.combobox.ComboBox<Object>,Object>,Object>, com.vaadin.flow.data.binder.HasValidator<Object>, com.vaadin.flow.data.provider.HasDataView<Object,String,com.vaadin.flow.component.combobox.dataview.ComboBoxDataView<Object>>, com.vaadin.flow.data.provider.HasLazyDataView<Object,String,com.vaadin.flow.component.combobox.dataview.ComboBoxLazyDataView<Object>>, com.vaadin.flow.data.provider.HasListDataView<Object,com.vaadin.flow.component.combobox.dataview.ComboBoxListDataView<Object>>, Serializable

public class FComboBox extends com.vaadin.flow.component.combobox.ComboBox<Object> implements Select, FAbstractComponent, FieldEvents.FocusNotifier, FieldEvents.BlurNotifier, HasSizeable
A Flow component that wraps a ComboBox and implements v7 functionalities that the Flow counterpart does not possess.
See Also:
  • Constructor Details

    • FComboBox

      public FComboBox()
      Constructs an empty FComboBox.
    • FComboBox

      public FComboBox(String caption)
      Constructs an empty FComboBox with the provided caption.
      Parameters:
      caption - the caption to set
    • FComboBox

      public FComboBox(String caption, Collection<?> options)
      Constructs a new FComboBox with the provided caption and options.
      Parameters:
      caption - the caption to set
      options - the options to set
    • FComboBox

      public FComboBox(String caption, Container dataSource)
      Constructs a new FComboBox with the provided caption and data source.
      Parameters:
      caption - the caption to set
      dataSource - the data source to set
  • Method Details

    • fireEvent

      protected void fireEvent(com.vaadin.flow.component.ComponentEvent<?> componentEvent)
      Overrides:
      fireEvent in class com.vaadin.flow.component.Component
    • setValue

      public void setValue(Object value)
      Description copied from interface: Property
      Sets the value of the Property.

      Implementing this functionality is optional. If the functionality is missing, one should declare the Property to be in read-only mode and throw Property.ReadOnlyException in this function.

      Note : Since Vaadin 7.0, setting the value of a non-String property as a String is no longer supported.
      Specified by:
      setValue in interface com.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.combobox.ComboBox<Object>,Object>,Object>
      Specified by:
      setValue in interface Property<Object>
      Specified by:
      setValue in interface Select
      Overrides:
      setValue in class com.vaadin.flow.component.combobox.ComboBoxBase<com.vaadin.flow.component.combobox.ComboBox<Object>,Object,Object>
      Parameters:
      value - New value of the Property. This should be assignable to the type returned by getType
    • getValue

      public Object getValue()
      Description copied from interface: Property
      Gets the value stored in the Property. The returned object is compatible with the class returned by getType().
      Specified by:
      getValue in interface com.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.combobox.ComboBox<Object>,Object>,Object>
      Specified by:
      getValue in interface Property<Object>
      Specified by:
      getValue in interface Select
      Overrides:
      getValue in class com.vaadin.flow.component.AbstractField<com.vaadin.flow.component.combobox.ComboBox<Object>,Object>
      Returns:
      the value stored in the Property
    • setTextInputAllowed

      public 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. By disabling text input, the comboBox will work in the same way as a select.
      Parameters:
      textInputAllowed - true to allow entering text, false to just show the current selection
      See Also:
    • isTextInputAllowed

      public boolean isTextInputAllowed()
      Returns true if the user can enter text into the field to either filter the selections or enter a new value if Select.isNewItemsAllowed() returns true. If text input is disabled, the combo box will work in the same way as a select.
    • setScrollToSelectedItem

      public 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. Only applies to single select mode. This requires finding the index of the item, which can be expensive in many large lazy loading containers.
      Parameters:
      scrollToSelectedItem - true to find the page with the selected item when opening the selection popup
    • isScrollToSelectedItem

      public boolean isScrollToSelectedItem()
      Returns true if the select should find the page with the selected item when opening the popup (single select combo box only).
      Returns:
      true if the page with the selected item will be shown when opening the popup
      See Also:
    • setPageLength

      public void setPageLength(int pageLength)
      Sets the page length for the suggestion popup. Setting the page length to 0 will disable suggestion popup paging (all items visible).
      Parameters:
      pageLength - the page length to set
      See Also:
    • getPageLength

      public int getPageLength()
      Returns the page length of the suggestion popup. A value of 0 disables paging.
      Returns:
      current page length
      See Also:
    • setPopupWidth

      public void setPopupWidth(String popupWidth)
      Sets the suggestion pop-up's width as a CSS string. By using relative units (e.g. "50%") it's possible to set the popup's width relative to the ComboBox itself.
      Parameters:
      popupWidth - the new width for the popup, or null to let it size automatically
      See Also:
    • getPopupWidth

      public String getPopupWidth()
      Returns the suggestion pop-up's width as a CSS string, or null if not set.
      Returns:
      the current popup width, or null
      See Also:
    • setItemLabelGenerator

      public void setItemLabelGenerator(com.vaadin.flow.component.ItemLabelGenerator<Object> itemLabelGenerator)
      Overrides:
      setItemLabelGenerator in class com.vaadin.flow.component.combobox.ComboBoxBase<com.vaadin.flow.component.combobox.ComboBox<Object>,Object,Object>
    • setFilteringMode

      public void setFilteringMode(FilteringMode filteringMode)
      Sets the option filtering mode.
      Parameters:
      filteringMode - the filtering mode to use
    • getFilteringMode

      public FilteringMode getFilteringMode()
      Gets the current filtering mode.
      Returns:
      the filtering mode in use
    • setItemStyleGenerator

      public void setItemStyleGenerator(ItemStyleGenerator itemStyleGenerator)
      Sets the item style generator that is used to produce custom styles for showing items in the popup. The CSS class name that will be added to the item style names is v-filterselect-item-[style name].
      Parameters:
      itemStyleGenerator - the item style generator to set, or null to not use any custom item styles
      Since:
      7.5.6
    • getItemStyleGenerator

      public ItemStyleGenerator getItemStyleGenerator()
      Gets the currently used item style generator.
      Returns:
      the itemStyleGenerator the currently used item style generator, or null if no generator is used
      Since:
      7.5.6
    • setNullSelectionAllowed

      public void setNullSelectionAllowed(boolean nullSelectionAllowed)
      Specified by:
      setNullSelectionAllowed in interface Select
    • setNullSelectionItemId

      public void setNullSelectionItemId(Object nullSelectionItemId)
      Sets the item id that represents null value of this select.

      Data interface does not support nulls as item ids. Selecting the item identified by this id is the same as selecting no items at all. This setting only affects the single select mode.

      Specified by:
      setNullSelectionItemId in interface Select
      Parameters:
      nullSelectionItemId - the nullSelectionItemId to set.
      See Also:
    • setLabel

      public void setLabel(String label)
      Specified by:
      setLabel in interface com.vaadin.flow.component.HasLabel
    • setLabelComponent

      public void setLabelComponent(com.vaadin.flow.component.Component labelComponent)
      Description copied from interface: FAbstractComponent
      Sets the component's label component. Flow components that support caption component usually overrides this.
      Specified by:
      setLabelComponent in interface FAbstractComponent
      Parameters:
      labelComponent - the new label component for the component.
    • setMultiSelect

      public void setMultiSelect(boolean multiSelect)
      Specified by:
      setMultiSelect in interface Select
    • isMultiSelect

      public boolean isMultiSelect()
      Specified by:
      isMultiSelect in interface Select
    • validate

      public void validate()
      Description copied from interface: Validatable

      Checks the validity of the validatable. If the validatable is valid this method should do nothing, and if it's not valid, it should throw Validator.InvalidValueException

      Specified by:
      validate in interface Select
      Specified by:
      validate in interface Validatable
      Overrides:
      validate in class com.vaadin.flow.component.combobox.ComboBoxBase<com.vaadin.flow.component.combobox.ComboBox<Object>,Object,Object>
    • addItems

      public void addItems(Object... itemIds) throws UnsupportedOperationException
      Adds given items with given item ids to container.
      Parameters:
      itemIds - item identifiers to be added to underlying container
      Throws:
      UnsupportedOperationException - if the underlying container don't support adding items with identifiers
      Since:
      7.2
    • addItems

      public void addItems(Collection<?> itemIds) throws UnsupportedOperationException
      Adds given items with given item ids to container.
      Parameters:
      itemIds - item identifiers to be added to underlying container
      Throws:
      UnsupportedOperationException - if the underlying container don't support adding items with identifiers
      Since:
      7.2
    • setItemCaption

      public void setItemCaption(Object itemId, String caption)
      Override the caption of an item. Setting caption explicitly overrides id, item and index captions.
      Parameters:
      itemId - the id of the item to be recaptioned.
      caption - the New caption.
    • setItemCaptionMode

      public void setItemCaptionMode(FAbstractSelect.ItemCaptionMode mode)
      Sets the item caption mode. See FAbstractSelect.ItemCaptionMode for a description of the modes.

      FAbstractSelect.ItemCaptionMode.EXPLICIT_DEFAULTS_ID is the default mode.

      Specified by:
      setItemCaptionMode in interface Select
      Parameters:
      mode - the One of the modes listed above.
    • getItemCaptionMode

      public FAbstractSelect.ItemCaptionMode getItemCaptionMode()
      Gets the item caption mode.

      The mode can be one of the following ones:

      • ITEM_CAPTION_MODE_EXPLICIT_DEFAULTS_ID : Items Id-objects toString is used as item caption. If caption is explicitly specified, it overrides the id-caption.
      • ITEM_CAPTION_MODE_ID : Items Id-objects toString is used as item caption.
      • ITEM_CAPTION_MODE_ITEM : Item-objects toString is used as item caption.
      • ITEM_CAPTION_MODE_INDEX : The index of the item is used as item caption. The index mode can only be used with the containers implementing Container.Indexed interface.
      • ITEM_CAPTION_MODE_EXPLICIT : The item captions must be explicitly specified.
      • ITEM_CAPTION_MODE_PROPERTY : The item captions are read from property, that must be specified with setItemCaptionPropertyId.
      The ITEM_CAPTION_MODE_EXPLICIT_DEFAULTS_ID is the default mode.

      Specified by:
      getItemCaptionMode in interface Select
      Returns:
      the One of the modes listed above.
    • setNewItemHandler

      public void setNewItemHandler(FAbstractSelect.NewItemHandler newItemHandler)
      Sets the new item handler. Called when a new item is added in newItemAllowed mode.
      Parameters:
      newItemHandler - The new item handler
    • getNewItemHandler

      public FAbstractSelect.NewItemHandler getNewItemHandler()
      Returns the new item handler, which is called when user adds new item in newItemAllowed mode.
      Returns:
      NewItemHandler
    • getType

      public Class<?> getType()
      Description copied from interface: Property
      Returns the type of the Property. The methods getValue and setValue must be compatible with this type: one must be able to safely cast the value returned from getValue to the given type and pass any variable assignable to this type as an argument to setValue.
      Specified by:
      getType in interface Field<Object>
      Specified by:
      getType in interface Property<Object>
      Returns:
      type of the Property
    • onAttach

      protected void onAttach(com.vaadin.flow.component.AttachEvent attachEvent)
      Overrides:
      onAttach in class com.vaadin.flow.component.combobox.ComboBoxBase<com.vaadin.flow.component.combobox.ComboBox<Object>,Object,Object>
    • onDetach

      protected void onDetach(com.vaadin.flow.component.DetachEvent detachEvent)
      Overrides:
      onDetach in class com.vaadin.flow.component.combobox.ComboBoxBase<com.vaadin.flow.component.combobox.ComboBox<Object>,Object,Object>
    • setRequired

      public void setRequired(boolean required)
      Description copied from interface: Field
      Sets the field required. Required fields must filled by the user.
      Specified by:
      setRequired in interface Field<Object>
      Overrides:
      setRequired in class com.vaadin.flow.component.combobox.ComboBoxBase<com.vaadin.flow.component.combobox.ComboBox<Object>,Object,Object>
      Parameters:
      required - Is the field required.
    • refreshValue

      protected void refreshValue()
      Overrides:
      refreshValue in class com.vaadin.flow.component.combobox.ComboBox<Object>