Class SearchSelect<T>

java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.AbstractField<SearchSelect<T>,T>
com.vaadin.flow.component.AbstractSinglePropertyField<SearchSelect<T>,T>
org.vaadin.firitin.fields.searchselect.SearchSelect<T>
Type Parameters:
T - the item type
All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier, com.vaadin.flow.component.BlurNotifier<SearchSelect<T>>, com.vaadin.flow.component.DetachNotifier, com.vaadin.flow.component.Focusable<SearchSelect<T>>, com.vaadin.flow.component.FocusNotifier<SearchSelect<T>>, 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.HasValidation, com.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<SearchSelect<T>,T>,T>, com.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<SearchSelect<T>,T>,T>, com.vaadin.flow.component.shared.HasClearButton, com.vaadin.flow.component.shared.HasTooltip, com.vaadin.flow.component.shared.HasValidationProperties, Serializable

@Deprecated(forRemoval=false) @Tag("vaadin-combo-box") @Uses(com.vaadin.flow.component.combobox.ComboBox.class) public class SearchSelect<T> extends com.vaadin.flow.component.AbstractSinglePropertyField<SearchSelect<T>,T> implements com.vaadin.flow.component.HasLabel, com.vaadin.flow.component.HasHelper, com.vaadin.flow.component.shared.HasValidationProperties, com.vaadin.flow.component.shared.HasClearButton, com.vaadin.flow.component.HasPlaceholder, com.vaadin.flow.component.HasSize, com.vaadin.flow.component.HasStyle, com.vaadin.flow.component.Focusable<SearchSelect<T>>, com.vaadin.flow.component.HasAriaLabel, com.vaadin.flow.component.shared.HasTooltip
Deprecated.
A new component with possibly changing API
Selects one item of a list, with search: semantically a Select (no custom values), but you can type to filter.

Small and medium lists (up to 1000 items by default) are sent to the browser once and filtered there: typing causes no server round trips at all; only the selected item is sent back. The default filter matches all typed words in any order, ignoring case and accents (see SearchMatching); provide your own with setClientFilter(String). Items can be found by more than their label with setSearchTextGenerator(ItemLabelGenerator).

Large lists — more in-memory items than the limit, or a backend query given with setItems(CallbackDataProvider.FetchCallback) — are filtered on the server, but only when the user pauses typing (300 ms by default), so a fluent typist causes one request rather than one per keystroke. Meanwhile, as long as the typed text refines the previous search, the previous results are narrowed down in the browser at once. At most 100 matches are shown; typing more narrows them down.

Renders as Vaadin's vaadin-combo-box web component (look, keyboard use, accessibility and theming as in the rest of a Vaadin app), driven by a small connector of its own instead of Flow's ComboBox — no custom frontend bundle needed.

See Also:
  • Nested Class Summary

    Nested classes/interfaces inherited from class com.vaadin.flow.component.AbstractField

    com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<C extends com.vaadin.flow.component.Component,V>

    Nested classes/interfaces inherited from interface com.vaadin.flow.component.BlurNotifier

    com.vaadin.flow.component.BlurNotifier.BlurEvent<C extends com.vaadin.flow.component.Component>

    Nested classes/interfaces inherited from interface com.vaadin.flow.component.Focusable

    com.vaadin.flow.component.Focusable.FocusJs

    Nested classes/interfaces inherited from interface com.vaadin.flow.component.FocusNotifier

    com.vaadin.flow.component.FocusNotifier.FocusEvent<C extends com.vaadin.flow.component.Component>

    Nested classes/interfaces inherited from interface com.vaadin.flow.component.HasValue

    com.vaadin.flow.component.HasValue.ValueChangeEvent<V>, com.vaadin.flow.component.HasValue.ValueChangeListener<E extends com.vaadin.flow.component.HasValue.ValueChangeEvent<?>>
  • Constructor Summary

    Constructors
    Constructor
    Description
    Deprecated.
     
    Deprecated.
     
    SearchSelect(String label, Collection<T> items)
    Deprecated.
     
  • Method Summary

    Modifier and Type
    Method
    Description
    filter(String filterText)
    Deprecated.
    The items shown for the given text: with in-memory items, those matching the default rule (the same the browser applies); with a backend query, its results.
    Deprecated.
     
    Deprecated.
     
    int
    Deprecated.
     
    com.vaadin.flow.component.ItemLabelGenerator<T>
    Deprecated.
     
    Deprecated.
    The in-memory items; empty when the items are queried from a backend (setItems(CallbackDataProvider.FetchCallback)).
    Deprecated.
    Deprecated.
     
    int
    Deprecated.
     
    boolean
    Deprecated.
    Whether filtering happens on the server (large list or backend query).
    boolean
    Deprecated.
    Whether a value is required; see setRequired(boolean).
    protected void
    onAttach(com.vaadin.flow.component.AttachEvent attachEvent)
    Deprecated.
     
    void
    setAriaLabel(String ariaLabel)
    Deprecated.
    The accessible name, for a field without a visible label (e.g. in a compact toolbar).
    void
    Deprecated.
     
    void
    setClientFilter(String functionBody)
    Deprecated.
    A custom filter, as the body of a JavaScript function (item, filter, normalize) => boolean: item.label and item.search are the item's label and search text, filter is the typed text and normalize(text) lower-cases and removes accents.
    void
    setClientSideItemLimit(int clientSideItemLimit)
    Deprecated.
    Up to how many in-memory items are filtered in the browser (default 1000); longer lists are filtered on the server.
    void
    setItemLabelGenerator(com.vaadin.flow.component.ItemLabelGenerator<T> itemLabelGenerator)
    Deprecated.
    How an item is shown (default: toString()).
    void
    setItems(com.vaadin.flow.data.provider.CallbackDataProvider.FetchCallback<T,String> fetch)
    Deprecated.
    Queries the items from a backend, e.g. a database, always filtered on the server.
    void
    Deprecated.
    The items to choose from, in the order shown.
    final void
    setItems(T... items)
    Deprecated.
     
    protected void
    Deprecated.
     
    void
    setRequired(boolean required)
    Deprecated.
    Whether a value is required: shows the required indicator, as HasValueAndElement.setRequiredIndicatorVisible(boolean) (which this is an alias for, as in ComboBox).
    void
    setSearchTextGenerator(com.vaadin.flow.component.ItemLabelGenerator<T> searchTextGenerator)
    Deprecated.
    The text searched for an item, when it should be found by more than its label, e.g. synonyms or codes (default: the label).
    void
    setServerFilterDelay(Duration serverFilterDelay)
    Deprecated.
    How long the user must pause typing before the filter is sent to the server (default 300 ms), when filtering on the server.
    void
    setServerResultLimit(int serverResultLimit)
    Deprecated.
    How many matches at most are shown when filtering on the server (default 100).

    Methods inherited from class com.vaadin.flow.component.AbstractSinglePropertyField

    getSynchronizationRegistration, hasValidValue, setSynchronizedEvent

    Methods inherited from class com.vaadin.flow.component.AbstractField

    addValueChangeListener, bindValue, getEmptyValue, getValue, isEmpty, setModelValue, setValue, valueEquals

    Methods inherited from class com.vaadin.flow.component.Component

    addListener, bindVisible, findAncestor, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTestId, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, getUIOrThrow, hasListener, isAttached, isTemplateMapped, isVisible, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setTestId, setVisible, whenAttached

    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.BlurNotifier

    addBlurListener

    Methods inherited from interface com.vaadin.flow.component.DetachNotifier

    addDetachListener

    Methods inherited from interface com.vaadin.flow.component.Focusable

    addFocusShortcut, blur, focus, focus, getTabIndex, setTabIndex

    Methods inherited from interface com.vaadin.flow.component.FocusNotifier

    addFocusListener

    Methods inherited from interface com.vaadin.flow.component.HasAriaLabel

    setAriaLabelledBy

    Methods inherited from interface com.vaadin.flow.component.shared.HasClearButton

    bindClearButtonVisible, isClearButtonVisible, setClearButtonVisible

    Methods inherited from interface com.vaadin.flow.component.HasElement

    getElement

    Methods inherited from interface com.vaadin.flow.component.HasEnabled

    bindEnabled, isEnabled, setEnabled

    Methods inherited from interface com.vaadin.flow.component.HasHelper

    bindHelperText, getHelperComponent, getHelperText, setHelperComponent, setHelperText

    Methods inherited from interface com.vaadin.flow.component.HasLabel

    getLabel, setLabel

    Methods inherited from interface com.vaadin.flow.component.HasPlaceholder

    bindPlaceholder, getPlaceholder, setPlaceholder

    Methods inherited from interface com.vaadin.flow.component.HasSize

    bindHeight, bindWidth, 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, bindClassName, bindClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName

    Methods inherited from interface com.vaadin.flow.component.shared.HasTooltip

    getTooltip, setTooltipMarkdown, setTooltipText

    Methods inherited from interface com.vaadin.flow.component.HasValidation

    setManualValidation

    Methods inherited from interface com.vaadin.flow.component.shared.HasValidationProperties

    getErrorMessage, isInvalid, setErrorMessage, setInvalid

    Methods inherited from interface com.vaadin.flow.component.HasValue

    clear, getOptionalValue

    Methods inherited from interface com.vaadin.flow.component.HasValueAndElement

    bindReadOnly, bindRequiredIndicatorVisible, isReadOnly, isRequiredIndicatorVisible, setReadOnly, setRequiredIndicatorVisible
  • Constructor Details

    • SearchSelect

      public SearchSelect()
      Deprecated.
    • SearchSelect

      public SearchSelect(String label)
      Deprecated.
    • SearchSelect

      public SearchSelect(String label, Collection<T> items)
      Deprecated.
  • Method Details

    • setRequired

      public void setRequired(boolean required)
      Deprecated.
      Whether a value is required: shows the required indicator, as HasValueAndElement.setRequiredIndicatorVisible(boolean) (which this is an alias for, as in ComboBox). Checking it is up to the server, e.g. Binder's asRequired().
    • isRequired

      public boolean isRequired()
      Deprecated.
      Whether a value is required; see setRequired(boolean).
    • setAriaLabel

      public void setAriaLabel(String ariaLabel)
      Deprecated.
      The accessible name, for a field without a visible label (e.g. in a compact toolbar). Set as the web component's accessibleName, as Vaadin's own fields do, so screen readers announce it on the input.
      Specified by:
      setAriaLabel in interface com.vaadin.flow.component.HasAriaLabel
    • getAriaLabel

      public Optional<String> getAriaLabel()
      Deprecated.
      Specified by:
      getAriaLabel in interface com.vaadin.flow.component.HasAriaLabel
    • setAriaLabelledBy

      public void setAriaLabelledBy(String labelledBy)
      Deprecated.
      Specified by:
      setAriaLabelledBy in interface com.vaadin.flow.component.HasAriaLabel
    • getAriaLabelledBy

      public Optional<String> getAriaLabelledBy()
      Deprecated.
      Specified by:
      getAriaLabelledBy in interface com.vaadin.flow.component.HasAriaLabel
    • setItems

      public void setItems(Collection<T> items)
      Deprecated.
      The items to choose from, in the order shown. Up to the client side item limit they are filtered in the browser, above it on the server with the default rule (SearchMatching.matchesAllWords(java.lang.String, java.lang.String) on the search text).
    • setItems

      @SafeVarargs public final void setItems(T... items)
      Deprecated.
    • setItems

      public void setItems(com.vaadin.flow.data.provider.CallbackDataProvider.FetchCallback<T,String> fetch)
      Deprecated.
      Queries the items from a backend, e.g. a database, always filtered on the server. The query's filter is the typed text (empty for "no filter"); its limit is the result limit. Example: select.setItems(query -> repository.findByNameContaining(query.getFilter().orElse(""), PageRequest.of(0, query.getLimit())).stream())

      SearchMatching.matchesAllWords(java.lang.String, java.lang.String) implements the default rule of the in-memory lists, if you want to match it.

    • getItems

      public List<T> getItems()
      Deprecated.
      The in-memory items; empty when the items are queried from a backend (setItems(CallbackDataProvider.FetchCallback)).
    • isFilteredOnServer

      public boolean isFilteredOnServer()
      Deprecated.
      Whether filtering happens on the server (large list or backend query).
    • setItemLabelGenerator

      public void setItemLabelGenerator(com.vaadin.flow.component.ItemLabelGenerator<T> itemLabelGenerator)
      Deprecated.
      How an item is shown (default: toString()).
    • getItemLabelGenerator

      public com.vaadin.flow.component.ItemLabelGenerator<T> getItemLabelGenerator()
      Deprecated.
    • setSearchTextGenerator

      public void setSearchTextGenerator(com.vaadin.flow.component.ItemLabelGenerator<T> searchTextGenerator)
      Deprecated.
      The text searched for an item, when it should be found by more than its label, e.g. synonyms or codes (default: the label). Not used with a backend query, which does its own matching.
    • getSearchText

      public String getSearchText(T item)
      Deprecated.
    • setClientFilter

      public void setClientFilter(String functionBody)
      Deprecated.
      A custom filter, as the body of a JavaScript function (item, filter, normalize) => boolean: item.label and item.search are the item's label and search text, filter is the typed text and normalize(text) lower-cases and removes accents. Example (prefix match): return normalize(item.label).startsWith(normalize(filter));

      When filtering on the server, this only narrows down the previous results while waiting for the server; make the server side match the same way.

      null restores the default: all words in any order, ignoring case and accents (SearchMatching.matchesAllWords(java.lang.String, java.lang.String)).

    • setClientSideItemLimit

      public void setClientSideItemLimit(int clientSideItemLimit)
      Deprecated.
      Up to how many in-memory items are filtered in the browser (default 1000); longer lists are filtered on the server.
    • getClientSideItemLimit

      public int getClientSideItemLimit()
      Deprecated.
    • setServerFilterDelay

      public void setServerFilterDelay(Duration serverFilterDelay)
      Deprecated.
      How long the user must pause typing before the filter is sent to the server (default 300 ms), when filtering on the server.
    • getServerFilterDelay

      public Duration getServerFilterDelay()
      Deprecated.
    • setServerResultLimit

      public void setServerResultLimit(int serverResultLimit)
      Deprecated.
      How many matches at most are shown when filtering on the server (default 100).
    • getServerResultLimit

      public int getServerResultLimit()
      Deprecated.
    • filter

      public List<T> filter(String filterText)
      Deprecated.
      The items shown for the given text: with in-memory items, those matching the default rule (the same the browser applies); with a backend query, its results. Handy in tests and server-side logic. Limited to the result limit when filtering on the server.
    • onAttach

      protected void onAttach(com.vaadin.flow.component.AttachEvent attachEvent)
      Deprecated.
      Overrides:
      onAttach in class com.vaadin.flow.component.Component
    • setPresentationValue

      protected void setPresentationValue(T value)
      Deprecated.
      Overrides:
      setPresentationValue in class com.vaadin.flow.component.AbstractSinglePropertyField<SearchSelect<T>,T>