Class CollectionField<T,​C extends Collection<T>>

    • 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 extends Object>
      • 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.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 extends Object>, com.vaadin.flow.component.HasValue.ValueChangeListener<E extends com.vaadin.flow.component.HasValue.ValueChangeEvent<?>>
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(int atIndex)
      Adds a new component at a specified position, moving subsequent elements by one.
      void focus()  
      protected C generateModelValue()  
      com.vaadin.flow.function.SerializablePredicate<T> getCollectionElementFilter()
      Returns current value filter.
      <W extends com.vaadin.flow.component.Component & com.vaadin.flow.component.HasValue<?,​T>>
      CollectionValueComponentProvider<T,​W>
      getCollectionValueComponentProvider()
      Returns the current provider used to generate components.
      void remove​(int atIndex)
      Removes a component at given index.
      void removeAll()
      Clears the collection and removes all elements from it.
      protected void repaintFields​(C ts)
      Paints all fields that need repainting and assigns values from the collection to each of them.
      void setCollectionElementFilter​(com.vaadin.flow.function.SerializablePredicate<T> collectionElementFilter)
      Sets a value filter.
      void setCollectionLayoutProvider​(CollectionLayoutProvider<?> collectionLayoutProvider)
      Sets new layout from a given provider and repaints all fields.
      void setCollectionValueComponentProvider​(CollectionValueComponentProvider<T,​?> collectionValueComponentProvider)
      Sets the provider used to generate components for each element of the collection.
      protected void setPresentationValue​(C ts)  
      void setReadOnly​(boolean readOnly)  
      int size()
      Returns the current size of the collection.
      protected void updateIndices​(int fromIndex)
      Updates all indices on all fields that implement HasIndex.
      protected void updateValue()  
      CollectionField<T,​C> withCollectionLayoutProvider​(CollectionLayoutProvider<?> collectionLayoutProvider)
      • Methods inherited from class com.vaadin.flow.component.customfield.CustomField

        add, addThemeVariants, getErrorMessage, getLabel, isInvalid, onAttach, remove, removeThemeVariants, setErrorMessage, setInvalid, setLabel
      • Methods inherited from class com.vaadin.flow.component.AbstractField

        addValueChangeListener, getEmptyValue, getValue, isEmpty, setModelValue, setValue, valueEquals
      • 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, onDetach, onEnabledStateChanged, scrollIntoView, set, setElement, setId, setVisible
      • 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, getTabIndex, setTabIndex
      • Methods inherited from interface com.vaadin.flow.component.FocusNotifier

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

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

        isEnabled, setEnabled
      • Methods inherited from interface com.vaadin.flow.component.HasHelper

        getHelperComponent, getHelperText, setHelperComponent, setHelperText
      • Methods inherited from interface com.vaadin.flow.component.HasLabel

        getLabel, setLabel
      • 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.HasTheme

        addThemeName, addThemeNames, getThemeName, getThemeNames, hasThemeName, removeThemeName, removeThemeNames, setThemeName, setThemeName
      • Methods inherited from interface com.vaadin.flow.component.shared.HasTooltip

        getTooltip, setTooltipText
      • 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, setRequiredIndicatorVisible
    • Field Detail

      • LAYOUT_STYLE_NAME

        public static final String LAYOUT_STYLE_NAME
        CSS class name that will be added to the main layout of this component.
        See Also:
        Constant Field Values
      • NO_ITEM_INDEX

        public static final int NO_ITEM_INDEX
        Integer value indicating no index being passed.
        See Also:
        Constant Field Values
      • DEFAULT_LAYOUT_PROVIDER

        public static final CollectionLayoutProvider<com.vaadin.flow.component.orderedlayout.FlexLayout> DEFAULT_LAYOUT_PROVIDER
        Default layout provider. Produces a column-based FlexLayout.
    • Constructor Detail

      • CollectionField

        public CollectionField​(com.vaadin.flow.function.SerializableSupplier<C> emptyCollectionSupplier,
                               com.vaadin.flow.function.SerializableSupplier<F> fieldSupplier)
        Creates new field using DEFAULT_LAYOUT_PROVIDER as root layout provider.
        Type Parameters:
        F - Type of the field used.
        Parameters:
        emptyCollectionSupplier - Provides an empty collection of elements.
        fieldSupplier - Method to call when a component for an element is needed.
      • CollectionField

        public CollectionField​(com.vaadin.flow.function.SerializableSupplier<C> emptyCollectionSupplier,
                               CollectionValueComponentProvider<T,​?> collectionValueComponentProvider)
        Creates new field using DEFAULT_LAYOUT_PROVIDER as root layout provider.
        Parameters:
        emptyCollectionSupplier - Provides an empty collection of elements.
        collectionValueComponentProvider - Provider for components for each element in the component.
      • CollectionField

        public CollectionField​(com.vaadin.flow.function.SerializableSupplier<C> emptyCollectionSupplier,
                               CollectionLayoutProvider<?> collectionLayoutProvider,
                               com.vaadin.flow.function.SerializableSupplier<F> fieldSupplier)
        Creates new field.
        Type Parameters:
        F - Type of the field used.
        Parameters:
        emptyCollectionSupplier - Provides an empty collection of elements.
        collectionLayoutProvider - Source of root layout for this component.
        fieldSupplier - Method to call when a component for an element is needed.
      • CollectionField

        public CollectionField​(com.vaadin.flow.function.SerializableSupplier<C> emptyCollectionSupplier,
                               CollectionLayoutProvider<?> collectionLayoutProvider,
                               CollectionValueComponentProvider<T,​?> collectionValueComponentProvider)
        Creates new field.
        Parameters:
        emptyCollectionSupplier - Provides an empty collection of elements.
        collectionLayoutProvider - Source of root layout for this component.
        collectionValueComponentProvider - Provider for components for each element in the component.
    • Method Detail

      • setCollectionLayoutProvider

        public final void setCollectionLayoutProvider​(CollectionLayoutProvider<?> collectionLayoutProvider)
        Sets new layout from a given provider and repaints all fields.
        Parameters:
        collectionLayoutProvider - A provider to use. Defaults to DEFAULT_LAYOUT_PROVIDER.
      • setReadOnly

        public void setReadOnly​(boolean readOnly)
        Specified by:
        setReadOnly in interface com.vaadin.flow.component.HasValue<T,​C extends Collection<T>>
        Specified by:
        setReadOnly in interface com.vaadin.flow.component.HasValueAndElement<T,​C extends Collection<T>>
      • generateModelValue

        protected C generateModelValue()
        Specified by:
        generateModelValue in class com.vaadin.flow.component.customfield.CustomField<C extends Collection<T>>
      • updateValue

        protected void updateValue()
        Overrides:
        updateValue in class com.vaadin.flow.component.customfield.CustomField<C extends Collection<T>>
      • setPresentationValue

        protected void setPresentationValue​(C ts)
        Specified by:
        setPresentationValue in class com.vaadin.flow.component.customfield.CustomField<C extends Collection<T>>
      • updateIndices

        protected void updateIndices​(int fromIndex)
        Updates all indices on all fields that implement HasIndex. This method is called after a component is removed or added, but before the value of the component is changed.
        Parameters:
        fromIndex - Index, from which the reindexing should occur.
      • add

        public void add​(int atIndex)
        Description copied from interface: CollectionController
        Adds a new component at a specified position, moving subsequent elements by one.
        Specified by:
        add in interface CollectionController
        Parameters:
        atIndex - Index to add at.
      • remove

        public void remove​(int atIndex)
        Description copied from interface: CollectionController
        Removes a component at given index. All subsequent components are moved forward by one.
        Specified by:
        remove in interface CollectionController
        Parameters:
        atIndex - Index to remove component at.
      • repaintFields

        protected void repaintFields​(C ts)
        Paints all fields that need repainting and assigns values from the collection to each of them.
        Parameters:
        ts - Collection with elements.
      • setCollectionElementFilter

        public void setCollectionElementFilter​(com.vaadin.flow.function.SerializablePredicate<T> collectionElementFilter)
        Description copied from interface: HasCollectionElementFilter
        Sets a value filter. Only items matching the filter will be included in the generated value.
        Specified by:
        setCollectionElementFilter in interface HasCollectionElementFilter<T>
        Parameters:
        collectionElementFilter - Value filter to use.
      • focus

        public void focus()
        Specified by:
        focus in interface com.vaadin.flow.component.Focusable<T>