Class ComboBoxDataView<T>

java.lang.Object
com.vaadin.flow.data.provider.AbstractDataView<T>
com.vaadin.flow.component.combobox.dataview.ComboBoxDataView<T>
Type Parameters:
T - the item type
All Implemented Interfaces:
com.vaadin.flow.data.provider.DataView<T>, Serializable

public class ComboBoxDataView<T> extends com.vaadin.flow.data.provider.AbstractDataView<T>
Implementation of generic data view for ComboBox. This implementation does not depend on a certain type of data provider, i.e. whether is it of in-memory or backend type. It can be used if the type of data provider is not either ListDataProvider or BackEndDataProvider.
See Also:
  • Field Summary

    Fields inherited from class com.vaadin.flow.data.provider.AbstractDataView

    component, dataProviderSupplier, NULL_IDENTIFIER_ERROR_MESSAGE, NULL_ITEM_ERROR_MESSAGE
  • Constructor Summary

    Constructors
    Constructor
    Description
    ComboBoxDataView(com.vaadin.flow.data.provider.DataCommunicator<T> dataCommunicator, ComboBoxBase<?,T,?> comboBox)
    Creates a new generic data view for ComboBox and verifies the passed data provider is compatible with this data view implementation.
  • Method Summary

    Modifier and Type
    Method
    Description
    com.vaadin.flow.shared.Registration
    addItemCountChangeListener(com.vaadin.flow.component.ComponentEventListener<com.vaadin.flow.data.provider.ItemCountChangeEvent<?>> listener)
    getItem(int index)
    Gets the item at the given index from the data available in the ComboBox's server-side.
    Gets the items available on the ComboBox's server-side.
    protected Class<?>
     
    void
    setIdentifierProvider(com.vaadin.flow.data.provider.IdentifierProvider<T> identifierProvider)
     

    Methods inherited from class com.vaadin.flow.data.provider.AbstractDataView

    addIdentifierProviderChangeListener, equals, getIdentifierProvider, getItemIndex, getItemIndex, getItems, refreshAll, refreshItem, verifyDataProviderType, verifyDataProviderType

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ComboBoxDataView

      public ComboBoxDataView(com.vaadin.flow.data.provider.DataCommunicator<T> dataCommunicator, ComboBoxBase<?,T,?> comboBox)
      Creates a new generic data view for ComboBox and verifies the passed data provider is compatible with this data view implementation.
      Parameters:
      dataCommunicator - the data communicator of the component
      comboBox - the ComboBox
  • Method Details

    • getItem

      public T getItem(int index)
      Gets the item at the given index from the data available in the ComboBox's server-side.

      This method does not take into account the ComboBox client-side filtering, since it doesn't change the item count on the server-side, but only makes it easier for users to search through the items in the UI.

      Parameters:
      index - item index number
      Returns:
      item on index
      Throws:
      IndexOutOfBoundsException - requested index is outside of the data set
    • getSupportedDataProviderType

      protected Class<?> getSupportedDataProviderType()
      Specified by:
      getSupportedDataProviderType in class com.vaadin.flow.data.provider.AbstractDataView<T>
    • getItems

      public Stream<T> getItems()
      Gets the items available on the ComboBox's server-side.

      This method does not take into account the ComboBox client-side filtering, since it doesn't change the item count on the server-side, but only makes it easier for users to search through the items in the UI.

      Specified by:
      getItems in interface com.vaadin.flow.data.provider.DataView<T>
      Overrides:
      getItems in class com.vaadin.flow.data.provider.AbstractDataView<T>
      Returns:
      items available on the server-side
    • setIdentifierProvider

      public void setIdentifierProvider(com.vaadin.flow.data.provider.IdentifierProvider<T> identifierProvider)
      Specified by:
      setIdentifierProvider in interface com.vaadin.flow.data.provider.DataView<T>
      Overrides:
      setIdentifierProvider in class com.vaadin.flow.data.provider.AbstractDataView<T>
    • addItemCountChangeListener

      public com.vaadin.flow.shared.Registration addItemCountChangeListener(com.vaadin.flow.component.ComponentEventListener<com.vaadin.flow.data.provider.ItemCountChangeEvent<?>> listener)

      Combo box fires ItemCountChangeEvent and notifies all the listeners added by this method, if the items count changed, for instance, due to adding or removing an item(s).

      ComboBox's client-side filter change won't fire ItemCountChangeEvent, since it doesn't change the item count on the server-side, but only makes it easier for users to search through the items in the UI.

      Specified by:
      addItemCountChangeListener in interface com.vaadin.flow.data.provider.DataView<T>
      Overrides:
      addItemCountChangeListener in class com.vaadin.flow.data.provider.AbstractDataView<T>