T - Type of the element in the collection.C - Type of the collection.@CssImport(value="./styles/label-positions-custom-field.css",
themeFor="vaadin-custom-field")
public class CollectionField<T,C extends Collection<T>>
extends com.vaadin.flow.component.customfield.CustomField<C>
implements CollectionController, WithIdMixin<CollectionField<T,C>>, com.vaadin.flow.component.HasStyle, WithCollectionValueComponentProviderMixin<T,CollectionField<T,C>>, WithHelperMixin<CollectionField<T,C>>, WithHelperPositionableMixin<CollectionField<T,C>>, WithValueMixin<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.customfield.CustomField<C>,C>,C,CollectionField<T,C>>, WithCollectionElementFilterMixin<T,CollectionField<T,C>>, WithLabelPositionableMixin<CollectionField<T,C>>, WithLabelMixin<CollectionField<T,C>>
Collections.
Allows filtering individual elements through setCollectionElementFilter(SerializablePredicate) (by default filters out all nulls).com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<C extends com.vaadin.flow.component.Component,V>com.vaadin.flow.component.HasValue.ValueChangeEvent<V>, com.vaadin.flow.component.HasValue.ValueChangeListener<E extends com.vaadin.flow.component.HasValue.ValueChangeEvent<?>>| Modifier and Type | Field and Description |
|---|---|
static CollectionLayoutProvider<com.vaadin.flow.component.orderedlayout.FlexLayout> |
DEFAULT_LAYOUT_PROVIDER
Default layout provider.
|
static String |
LAYOUT_STYLE_NAME
CSS class name that will be added to the main layout of this component.
|
static int |
NO_ITEM_INDEX
Integer value indicating no index being passed.
|
HELPER_ABOVE_THEME_VARIANTLABEL_POSITION_ATTRIBUTE, LABEL_POSITION_DETAILS_ATTRIBUTE| Constructor and Description |
|---|
CollectionField(com.vaadin.flow.function.SerializableSupplier<C> emptyCollectionSupplier,
CollectionLayoutProvider<?> collectionLayoutProvider,
CollectionValueComponentProvider<T,?> collectionValueComponentProvider)
Creates new field.
|
CollectionField(com.vaadin.flow.function.SerializableSupplier<C> emptyCollectionSupplier,
CollectionLayoutProvider<?> collectionLayoutProvider,
com.vaadin.flow.function.SerializableSupplier<F> fieldSupplier)
Creates new field.
|
CollectionField(com.vaadin.flow.function.SerializableSupplier<C> emptyCollectionSupplier,
CollectionValueComponentProvider<T,?> collectionValueComponentProvider)
Creates new field using
DEFAULT_LAYOUT_PROVIDER as root layout provider. |
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. |
| Modifier and Type | Method and 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>> |
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)
Chains
setCollectionLayoutProvider(CollectionLayoutProvider) and returns itself. |
add, getErrorMessage, getLabel, isInvalid, remove, setErrorMessage, setInvalid, setLabeladdValueChangeListener, getEmptyValue, getValue, isEmpty, setModelValue, setValue, valueEqualsaddListener, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, set, setElement, setId, setVisibleclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitadd, isEmpty, removewithIdaddClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassNamewithCollectionComponentProviderwithHelperComponent, withHelperTextgetHelperComponent, getHelperText, setHelperComponent, setHelperTextwithHelperAbove, withHelperAbove, withHelperBelowisHelperAbove, setHelperAbove, setHelperAbove, setHelperBelowwithValueaddValueChangeListener, clear, getEmptyValue, getOptionalValue, getValue, isEmpty, isReadOnly, isRequiredIndicatorVisible, setRequiredIndicatorVisible, setValuewithCollectionElementFilterwithLabelPositiongetLabelPosition, setLabelPositionwithLabelgetCssSize, getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFulladdFocusShortcut, blur, getTabIndex, setTabIndexpublic static final String LAYOUT_STYLE_NAME
public static final int NO_ITEM_INDEX
public static final CollectionLayoutProvider<com.vaadin.flow.component.orderedlayout.FlexLayout> DEFAULT_LAYOUT_PROVIDER
FlexLayout.public CollectionField(com.vaadin.flow.function.SerializableSupplier<C> emptyCollectionSupplier, com.vaadin.flow.function.SerializableSupplier<F> fieldSupplier)
DEFAULT_LAYOUT_PROVIDER as root layout provider.F - Type of the field used.emptyCollectionSupplier - Provides an empty collection of elements.fieldSupplier - Method to call when a component for an element is needed.public CollectionField(com.vaadin.flow.function.SerializableSupplier<C> emptyCollectionSupplier, CollectionValueComponentProvider<T,?> collectionValueComponentProvider)
DEFAULT_LAYOUT_PROVIDER as root layout provider.emptyCollectionSupplier - Provides an empty collection of elements.collectionValueComponentProvider - Provider for components for each element in the component.public CollectionField(com.vaadin.flow.function.SerializableSupplier<C> emptyCollectionSupplier, CollectionLayoutProvider<?> collectionLayoutProvider, com.vaadin.flow.function.SerializableSupplier<F> fieldSupplier)
F - Type of the field used.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.public CollectionField(com.vaadin.flow.function.SerializableSupplier<C> emptyCollectionSupplier, CollectionLayoutProvider<?> collectionLayoutProvider, CollectionValueComponentProvider<T,?> collectionValueComponentProvider)
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.public final void setCollectionLayoutProvider(CollectionLayoutProvider<?> collectionLayoutProvider)
collectionLayoutProvider - A provider to use. Defaults to DEFAULT_LAYOUT_PROVIDER.public final CollectionField<T,C> withCollectionLayoutProvider(CollectionLayoutProvider<?> collectionLayoutProvider)
setCollectionLayoutProvider(CollectionLayoutProvider) and returns itself.collectionLayoutProvider - A provider to use. Defaults to DEFAULT_LAYOUT_PROVIDER.setCollectionLayoutProvider(CollectionLayoutProvider)public void setReadOnly(boolean readOnly)
setReadOnly in interface com.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.customfield.CustomField<C extends Collection<T>>,C extends Collection<T>>,C extends Collection<T>>setReadOnly in interface com.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.customfield.CustomField<C extends Collection<T>>,C extends Collection<T>>,C extends Collection<T>>protected C generateModelValue()
generateModelValue in class com.vaadin.flow.component.customfield.CustomField<C extends Collection<T>>protected void updateValue()
updateValue in class com.vaadin.flow.component.customfield.CustomField<C extends Collection<T>>protected void setPresentationValue(C ts)
setPresentationValue in class com.vaadin.flow.component.customfield.CustomField<C extends Collection<T>>public int size()
CollectionControllersize in interface CollectionControllerprotected void updateIndices(int fromIndex)
HasIndex.
This method is called after a component is removed or added, but before the value of the component is changed.fromIndex - Index, from which the reindexing should occur.public void add(int atIndex)
CollectionControlleradd in interface CollectionControlleratIndex - Index to add at.public void remove(int atIndex)
CollectionControllerremove in interface CollectionControlleratIndex - Index to remove component at.public void removeAll()
CollectionControllerremoveAll in interface CollectionControllerprotected void repaintFields(C ts)
ts - Collection with elements.public final void setCollectionValueComponentProvider(CollectionValueComponentProvider<T,?> collectionValueComponentProvider)
HasCollectionValueComponentProvidersetCollectionValueComponentProvider in interface HasCollectionValueComponentProvider<T>collectionValueComponentProvider - A non-null provider.public <W extends com.vaadin.flow.component.Component & com.vaadin.flow.component.HasValue<?,T>> CollectionValueComponentProvider<T,W> getCollectionValueComponentProvider()
HasCollectionValueComponentProvidergetCollectionValueComponentProvider in interface HasCollectionValueComponentProvider<T>W - Generic type of the actual component.null provider.public void setCollectionElementFilter(com.vaadin.flow.function.SerializablePredicate<T> collectionElementFilter)
HasCollectionElementFiltersetCollectionElementFilter in interface HasCollectionElementFilter<T>collectionElementFilter - Value filter to use.public com.vaadin.flow.function.SerializablePredicate<T> getCollectionElementFilter()
HasCollectionElementFiltergetCollectionElementFilter in interface HasCollectionElementFilter<T>null filter.public void focus()
focus in interface com.vaadin.flow.component.Focusable<com.vaadin.flow.component.customfield.CustomField>Copyright © 2023 Miki. All rights reserved.