Class AbstractLookupField<T,SelectT,ComboboxT extends com.vaadin.flow.component.HasEnabled & com.vaadin.flow.component.HasValidation & com.vaadin.flow.component.HasSize & com.vaadin.flow.component.HasValue<?,SelectT>,ComponentT extends AbstractLookupField<T,SelectT,ComboboxT,ComponentT,FilterType>,FilterType>

java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.HtmlComponent
com.vaadin.flow.component.HtmlContainer
com.vaadin.flow.component.html.Div
com.vaadin.componentfactory.lookupfield.AbstractLookupField<T,SelectT,ComboboxT,ComponentT,FilterType>
All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier, com.vaadin.flow.component.ClickNotifier<com.vaadin.flow.component.html.Div>, com.vaadin.flow.component.DetachNotifier, com.vaadin.flow.component.HasComponents, com.vaadin.flow.component.HasElement, com.vaadin.flow.component.HasEnabled, com.vaadin.flow.component.HasOrderedComponents, com.vaadin.flow.component.HasSize, com.vaadin.flow.component.HasStyle, com.vaadin.flow.component.HasText, com.vaadin.flow.component.HasTheme, com.vaadin.flow.component.HasValidation, com.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<ComponentT,SelectT>,SelectT>, com.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<ComponentT,SelectT>,SelectT>, com.vaadin.flow.data.binder.HasFilterableDataProvider<T,FilterType>, com.vaadin.flow.data.binder.HasItems<T>, Serializable
Direct Known Subclasses:
CustomFilterLookupField, CustomFilterMultiSelectLookupField

@Uses(com.vaadin.flow.component.icon.Icon.class) @Uses(com.vaadin.flow.component.textfield.TextField.class) @Uses(com.vaadin.flow.component.button.Button.class) @Tag("vcf-lookup-field") @JsModule("@vaadin-component-factory/vcf-lookup-field") @NpmPackage(value="@vaadin-component-factory/vcf-lookup-field", version="6.0.2") @CssImport("./lookup-dialog-themes.css") public abstract class AbstractLookupField<T,SelectT,ComboboxT extends com.vaadin.flow.component.HasEnabled & com.vaadin.flow.component.HasValidation & com.vaadin.flow.component.HasSize & com.vaadin.flow.component.HasValue<?,SelectT>,ComponentT extends AbstractLookupField<T,SelectT,ComboboxT,ComponentT,FilterType>,FilterType> extends com.vaadin.flow.component.html.Div implements com.vaadin.flow.data.binder.HasFilterableDataProvider<T,FilterType>, com.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<ComponentT,SelectT>,SelectT>, com.vaadin.flow.component.HasValidation, com.vaadin.flow.component.HasSize, com.vaadin.flow.component.HasTheme
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
     
    static class 
     
    static class 
    The internationalization properties for LookupField.

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

    com.vaadin.flow.component.HasText.WhiteSpace

    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<?>>
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected ComboboxT
     
    protected static final String
     
    protected final com.vaadin.flow.function.SerializableFunction<String,FilterType>
     
    protected final com.vaadin.flow.function.SerializableFunction<FilterType,String>
     
    protected static final String
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    AbstractLookupField(com.vaadin.flow.function.SerializableFunction<String,FilterType> filterConverter, com.vaadin.flow.function.SerializableFunction<FilterType,String> invertedFilterConverter)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    com.vaadin.flow.shared.Registration
    addCreateItemListener(com.vaadin.flow.component.ComponentEventListener<AbstractLookupField.CreateItemEvent> listener)
    Add an action when the user click on create item
    void
    addEmptySelectionListener(Runnable notificationWhenEmptySelection)
    Replace the default notification to an action
    com.vaadin.flow.shared.Registration
    addFilterListener(com.vaadin.flow.component.ComponentEventListener<AbstractLookupField.FilterEvent<FilterType>> listener)
    Add an action when the user filters
    void
    Adds the theme variants of this component.
    protected abstract void
    Copy the selected value of the grid into the field
    protected abstract void
    Copy the selected value of the field into the grid
    void
    Close the dialog
    void
    Select and close the dialog
    abstract ComboboxT
     
     
    com.vaadin.flow.component.grid.Grid<T>
     
    Gets the internationalization object previously set for this component.
    boolean
    Gets whether the select button is disabled or send an error when the selection is empty or not.
    boolean
    Gets whether dialog is enabled to be dragged or not.
    boolean
     
    boolean
    Gets whether component is set as modal or modeless dialog.
    boolean
    Gets whether dialog is enabled to be resized or not.
    void
     
    abstract void
    Set the comboBox
    void
    setCreateVisible(boolean createVisible)
     
    abstract void
    setDataProvider(com.vaadin.flow.component.combobox.ComboBox.ItemFilter<T> itemFilter, com.vaadin.flow.data.provider.ListDataProvider<T> listDataProvider)
    Sets a list data provider with an item filter as the data provider.
    <C> void
    setDataProvider(com.vaadin.flow.data.provider.DataProvider<T,C> dataProvider, com.vaadin.flow.function.SerializableFunction<FilterType,C> filterConverter)
     
    abstract void
    setDataProvider(com.vaadin.flow.data.provider.ListDataProvider<T> listDataProvider)
     
    void
    setDraggable(boolean draggable)
    Sets whether dialog is enabled to be dragged by the user or not.
    void
    setEnabled(boolean enabled)
     
    void
    setErrorMessage(String errorMessage)
     
    void
    Set the filter with a custom component
    void
    setFooterComponent(com.vaadin.flow.component.Component footer)
    Set the footer with a custom component WARNING: You have to implement your own buttons to select and close the dialog
    void
    setGrid(com.vaadin.flow.component.grid.Grid<T> grid)
    Set the grid
    void
    Set the width of the grid Also set a max width to 100%
    void
    setHeader(String header)
    Set the header of the dialog
    void
    setHeaderComponent(com.vaadin.flow.component.Component header)
    Set the header with a custom component
    void
    Sets the internationalization properties for this component.
    void
    setInvalid(boolean invalid)
     
    abstract 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
    setItems(com.vaadin.flow.component.combobox.ComboBox.ItemFilter<T> itemFilter, Collection<T> items)
     
    void
    Filtering will use a case insensitive match to show all items where the filter text is a substring of the label displayed for that item, which you can configure with setItemLabelGenerator(ItemLabelGenerator).
    abstract void
    Set the label of the field
    void
    setModal(boolean modal)
    Sets whether component will open modal or modeless dialog.
    void
    setReadOnly(boolean readOnly)
     
    void
    setRequiredIndicatorVisible(boolean requiredIndicatorVisible)
     
    void
    setResizable(boolean resizable)
    Sets whether dialog can be resized by user or not.
    void
    setSelectionDisabledIfEmpty(boolean defaultselectdisabled)
    Sets whether the select button is disabled or send an error when the selection is empty or not.
    void
    Sets the theme variants of this component.

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

    getTitle, setTitle

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

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

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

    addClickListener, addClickShortcut, addDoubleClickListener, addSingleClickListener

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

    addDetachListener

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

    add, add, add, addComponentAsFirst, addComponentAtIndex, remove, remove, removeAll

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

    getElement

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

    isEnabled

    Methods inherited from interface com.vaadin.flow.data.binder.HasFilterableDataProvider

    setDataProvider

    Methods inherited from interface com.vaadin.flow.data.binder.HasItems

    setItems, setItems

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

    getChildren, getComponentAt, getComponentCount, indexOf, replace

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

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

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

    getText, getWhiteSpace, setText, setWhiteSpace

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

    addThemeName, addThemeNames, getThemeName, getThemeNames, hasThemeName, removeThemeName, removeThemeNames, setThemeName, setThemeName

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

    setManualValidation

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

    addValueChangeListener, clear, getEmptyValue, getOptionalValue, getValue, isEmpty, setValue

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

    isReadOnly, isRequiredIndicatorVisible
  • Field Details

    • FIELD_SLOT_NAME

      protected static final String FIELD_SLOT_NAME
      See Also:
    • SLOT_KEY

      protected static final String SLOT_KEY
      See Also:
    • comboBox

      protected ComboboxT extends com.vaadin.flow.component.HasEnabled & com.vaadin.flow.component.HasValidation & com.vaadin.flow.component.HasSize & com.vaadin.flow.component.HasValue<?,SelectT> comboBox
    • filterConverter

      protected final com.vaadin.flow.function.SerializableFunction<String,FilterType> filterConverter
    • invertedFilterConverter

      protected final com.vaadin.flow.function.SerializableFunction<FilterType,String> invertedFilterConverter
  • Constructor Details

    • AbstractLookupField

      public AbstractLookupField(com.vaadin.flow.function.SerializableFunction<String,FilterType> filterConverter, com.vaadin.flow.function.SerializableFunction<FilterType,String> invertedFilterConverter)
  • Method Details

    • setGrid

      public void setGrid(com.vaadin.flow.component.grid.Grid<T> grid)
      Set the grid
      Parameters:
      grid - the grid
    • setComboBox

      public abstract void setComboBox(ComboboxT comboBox)
      Set the comboBox
      Parameters:
      comboBox - the comboBox
    • getComboBox

      public abstract ComboboxT getComboBox()
      Returns:
      the internal field
    • setItems

      public void setItems(Collection<T> items)

      Filtering will use a case insensitive match to show all items where the filter text is a substring of the label displayed for that item, which you can configure with setItemLabelGenerator(ItemLabelGenerator).

      Specified by:
      setItems in interface com.vaadin.flow.data.binder.HasItems<T>
      Parameters:
      items - the data items to display
    • setItems

      public void setItems(com.vaadin.flow.component.combobox.ComboBox.ItemFilter<T> itemFilter, Collection<T> items)
      Parameters:
      itemFilter - filter to check if an item is shown when user typed some text into the ComboBox
      items - the data items to display
    • setDataProvider

      public abstract void setDataProvider(com.vaadin.flow.data.provider.ListDataProvider<T> listDataProvider)
    • setDataProvider

      public abstract void setDataProvider(com.vaadin.flow.component.combobox.ComboBox.ItemFilter<T> itemFilter, com.vaadin.flow.data.provider.ListDataProvider<T> listDataProvider)
      Sets a list data provider with an item filter as the data provider.
      Parameters:
      itemFilter - filter to check if an item is shown when user typed some text into the ComboBox
      listDataProvider - the list data provider to use, not null
    • setDataProvider

      public <C> void setDataProvider(com.vaadin.flow.data.provider.DataProvider<T,C> dataProvider, com.vaadin.flow.function.SerializableFunction<FilterType,C> filterConverter)
      Specified by:
      setDataProvider in interface com.vaadin.flow.data.binder.HasFilterableDataProvider<T,SelectT>
    • getGrid

      public com.vaadin.flow.component.grid.Grid<T> getGrid()
      Returns:
      the internal grid
    • copyFieldValueFromGrid

      protected abstract void copyFieldValueFromGrid()
      Copy the selected value of the grid into the field
    • copyFieldValueToGrid

      protected abstract void copyFieldValueToGrid()
      Copy the selected value of the field into the grid
    • setItemLabelGenerator

      public abstract 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. By default, String.valueOf(Object) is used.

      Parameters:
      itemLabelGenerator - the item label provider to use, not null
    • setGridWidth

      public void setGridWidth(String width)
      Set the width of the grid Also set a max width to 100%
      Parameters:
      width - the width to set, may be null
    • setThemeVariants

      public void setThemeVariants(LookupFieldVariant variants)
      Sets the theme variants of this component. This method overwrites any previous set theme variants.
      Parameters:
      variants - theme variant
    • addThemeVariants

      public void addThemeVariants(LookupFieldVariant... variants)
      Adds the theme variants of this component.
      Parameters:
      variants - theme variant
    • setHeader

      public void setHeader(String header)
      Set the header of the dialog
      Parameters:
      header - text for the header of the dialog
    • setLabel

      public abstract void setLabel(String label)
      Set the label of the field
      Parameters:
      label - label of the field
    • setModal

      public void setModal(boolean modal)
      Sets whether component will open modal or modeless dialog.

      Note: When dialog is set to be modeless, then it's up to you to provide means for it to be closed (eg. a button that calls Dialog.close()). The reason being that a modeless dialog allows user to interact with the interface under it and won't be closed by clicking outside or the ESC key.

      Parameters:
      modal - false to enable dialog to open as modeless modal, true otherwise.
    • isModal

      public boolean isModal()
      Gets whether component is set as modal or modeless dialog.
      Returns:
      true if modal dialog (default), false otherwise.
    • setDraggable

      public void setDraggable(boolean draggable)
      Sets whether dialog is enabled to be dragged by the user or not.

      To allow an element inside the dialog to be dragged by the user (for instance, a header inside the dialog), a class "draggable" can be added to it (see HasStyle.addClassName(String)).

      Note: If draggable is enabled and dialog is opened without first being explicitly attached to a parent, then it won't restore its last position in the case the user closes and opens it again. Reason being that a self attached dialog is removed from the DOM when it's closed and position is not synched.

      Parameters:
      draggable - true to enable dragging of the dialog, false otherwise
    • isDraggable

      public boolean isDraggable()
      Gets whether dialog is enabled to be dragged or not.
      Returns:
      true if dragging is enabled, false otherwise (default).
    • setResizable

      public void setResizable(boolean resizable)
      Sets whether dialog can be resized by user or not.
      Parameters:
      resizable - true to enabled resizing of the dialog, false otherwise.
    • isResizable

      public boolean isResizable()
      Gets whether dialog is enabled to be resized or not.
      Returns:
      true if resizing is enabled, false otherwiser (default).
    • setSelectionDisabledIfEmpty

      public void setSelectionDisabledIfEmpty(boolean defaultselectdisabled)
      Sets whether the select button is disabled or send an error when the selection is empty or not.
      Parameters:
      defaultselectdisabled - true to disabled the button if no item is disabled, false otherwise.
    • getSelectionDisabledIfEmpty

      public boolean getSelectionDisabledIfEmpty()
      Gets whether the select button is disabled or send an error when the selection is empty or not.
      Returns:
      true if resizing is enabled, false otherwiser (default).
    • getI18n

      Gets the internationalization object previously set for this component.

      Note: updating the object content that is gotten from this method will not update the lang on the component if not set back using setI18n(LookupFieldI18n)

      Returns:
      the i18n object. It will be null, If the i18n properties weren't set.
    • setI18n

      public void setI18n(AbstractLookupField.LookupFieldI18n i18n)
      Sets the internationalization properties for this component.
      Parameters:
      i18n - the internationalized properties, not null
    • isInvalid

      public boolean isInvalid()
      Specified by:
      isInvalid in interface com.vaadin.flow.component.HasValidation
    • setInvalid

      public void setInvalid(boolean invalid)
      Specified by:
      setInvalid in interface com.vaadin.flow.component.HasValidation
    • setReadOnly

      public void setReadOnly(boolean readOnly)
      Specified by:
      setReadOnly in interface com.vaadin.flow.component.HasValue<T,SelectT>
      Specified by:
      setReadOnly in interface com.vaadin.flow.component.HasValueAndElement<T,SelectT>
    • setEnabled

      public void setEnabled(boolean enabled)
      Specified by:
      setEnabled in interface com.vaadin.flow.component.HasEnabled
    • setErrorMessage

      public void setErrorMessage(String errorMessage)
      Specified by:
      setErrorMessage in interface com.vaadin.flow.component.HasValidation
    • getErrorMessage

      public String getErrorMessage()
      Specified by:
      getErrorMessage in interface com.vaadin.flow.component.HasValidation
    • setRequiredIndicatorVisible

      public void setRequiredIndicatorVisible(boolean requiredIndicatorVisible)
      Specified by:
      setRequiredIndicatorVisible in interface com.vaadin.flow.component.HasValue<T,SelectT>
      Specified by:
      setRequiredIndicatorVisible in interface com.vaadin.flow.component.HasValueAndElement<T,SelectT>
    • setHeaderComponent

      public void setHeaderComponent(com.vaadin.flow.component.Component header)
      Set the header with a custom component
      Parameters:
      header - custom header
    • setFilter

      public void setFilter(LookupFieldFilter<FilterType> filter)
      Set the filter with a custom component
      Parameters:
      filter - custom filter
    • setFooterComponent

      public void setFooterComponent(com.vaadin.flow.component.Component footer)
      Set the footer with a custom component WARNING: You have to implement your own buttons to select and close the dialog
      Parameters:
      footer - Custom footer
    • footerSelectAction

      public void footerSelectAction()
      Select and close the dialog
    • footerCloseAction

      public void footerCloseAction()
      Close the dialog
    • addEmptySelectionListener

      public void addEmptySelectionListener(Runnable notificationWhenEmptySelection)
      Replace the default notification to an action
      Parameters:
      notificationWhenEmptySelection - action to run when the selection is empty and the select button is clicked
    • addFilterListener

      public com.vaadin.flow.shared.Registration addFilterListener(com.vaadin.flow.component.ComponentEventListener<AbstractLookupField.FilterEvent<FilterType>> listener)
      Add an action when the user filters
      Parameters:
      listener - the listener to add, not null
      Returns:
      a handle that can be used for removing the listener
    • addCreateItemListener

      public com.vaadin.flow.shared.Registration addCreateItemListener(com.vaadin.flow.component.ComponentEventListener<AbstractLookupField.CreateItemEvent> listener)
      Add an action when the user click on create item
      Parameters:
      listener - the listener to add, not null
      Returns:
      a handle that can be used for removing the listener
    • setCreateVisible

      public void setCreateVisible(boolean createVisible)
    • open

      public void open()