Class ObjectField<T>
- java.lang.Object
-
- com.vaadin.flow.component.Component
-
- com.vaadin.flow.component.AbstractField<com.vaadin.flow.component.customfield.CustomField<T>,T>
-
- com.vaadin.flow.component.customfield.CustomField<T>
-
- org.vaadin.miki.superfields.object.ObjectField<T>
-
- All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier,com.vaadin.flow.component.BlurNotifier<com.vaadin.flow.component.customfield.CustomField>,com.vaadin.flow.component.DetachNotifier,com.vaadin.flow.component.Focusable<com.vaadin.flow.component.customfield.CustomField>,com.vaadin.flow.component.FocusNotifier<com.vaadin.flow.component.customfield.CustomField>,com.vaadin.flow.component.HasElement,com.vaadin.flow.component.HasEnabled,com.vaadin.flow.component.HasHelper,com.vaadin.flow.component.HasLabel,com.vaadin.flow.component.HasSize,com.vaadin.flow.component.HasStyle,com.vaadin.flow.component.HasTheme,com.vaadin.flow.component.HasValidation,com.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.customfield.CustomField<T>,T>,T>,com.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.customfield.CustomField<T>,T>,T>,com.vaadin.flow.component.shared.HasTooltip,Serializable,HasHelperPositionable,HasId,HasLabelPositionable,WithHelperMixin<ObjectField<T>>,WithHelperPositionableMixin<ObjectField<T>>,WithIdMixin<ObjectField<T>>,WithLabelMixin<ObjectField<T>>,WithLabelPositionableMixin<ObjectField<T>>,WithValueMixin<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.customfield.CustomField<T>,T>,T,ObjectField<T>>
@CssImport(value="./styles/label-positions.css", themeFor="vaadin-custom-field") public class ObjectField<T> extends com.vaadin.flow.component.customfield.CustomField<T> implements com.vaadin.flow.component.HasStyle, WithHelperMixin<ObjectField<T>>, WithHelperPositionableMixin<ObjectField<T>>, WithIdMixin<ObjectField<T>>, WithLabelMixin<ObjectField<T>>, WithLabelPositionableMixin<ObjectField<T>>, WithValueMixin<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.customfield.CustomField<T>,T>,T,ObjectField<T>>A field capable of displaying any object, provided it is known how to construct various elements of it. Construction of the field happens in stages:- obtain properties of the object
- group properties
- map each property to a component capable of showing that property
- configure components (individually and in defined groups)
- set value of each component
- Since:
- 2022-05-16
- Author:
- miki
- See Also:
- Serialized Form
-
-
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<?>>
-
-
Field Summary
Fields Modifier and Type Field Description static com.vaadin.flow.function.SerializableSupplier<PropertyComponentBuilder>DEFAULT_COMPONENT_BUILDERstatic com.vaadin.flow.function.SerializableSupplier<PropertyGroupLayoutProvider>DEFAULT_GROUP_LAYOUT_PROVIDERstatic com.vaadin.flow.function.SerializableSupplier<PropertyGroupingProvider>DEFAULT_GROUPING_PROVIDERstatic com.vaadin.flow.function.SerializableSupplier<com.vaadin.flow.component.orderedlayout.FlexLayout>DEFAULT_LAYOUT_PROVIDERstatic com.vaadin.flow.function.SerializableSupplier<PropertyProvider>DEFAULT_PROPERTY_PROVIDER-
Fields inherited from interface org.vaadin.miki.markers.HasHelperPositionable
HELPER_ABOVE_THEME_VARIANT
-
Fields inherited from interface org.vaadin.miki.markers.HasLabelPositionable
LABEL_POSITION_ATTRIBUTE, LABEL_POSITION_DETAILS_ATTRIBUTE
-
-
Constructor Summary
Constructors Constructor Description ObjectField(Class<T> dataType, com.vaadin.flow.function.SerializableSupplier<T> emptyObjectSupplier)Builds anObjectFieldusingDEFAULT_LAYOUT_PROVIDERfor the main layout.ObjectField(Class<T> dataType, com.vaadin.flow.function.SerializableSupplier<T> emptyObjectSupplier, com.vaadin.flow.function.SerializableSupplier<L> layoutSupplier)Builds anObjectFieldusing a given supplier for the main layout.
-
Method Summary
-
Methods inherited from class com.vaadin.flow.component.customfield.CustomField
add, addThemeVariants, getErrorMessage, getLabel, isInvalid, onAttach, remove, removeThemeVariants, setErrorMessage, setInvalid, setLabel, updateValue
-
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 class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.vaadin.flow.component.Focusable
addFocusShortcut, blur, getTabIndex, setTabIndex
-
Methods inherited from interface com.vaadin.flow.component.HasHelper
getHelperComponent, getHelperText, setHelperComponent, setHelperText
-
Methods inherited from interface org.vaadin.miki.markers.HasHelperPositionable
isHelperAbove, setHelperAbove, setHelperAbove, setHelperBelow
-
Methods inherited from interface org.vaadin.miki.markers.HasLabelPositionable
getLabelPosition, setLabelPosition
-
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
-
Methods inherited from interface org.vaadin.miki.markers.WithHelperMixin
withHelperComponent, withHelperText
-
Methods inherited from interface org.vaadin.miki.markers.WithHelperPositionableMixin
withHelperAbove, withHelperAbove, withHelperBelow
-
Methods inherited from interface org.vaadin.miki.markers.WithIdMixin
withId
-
Methods inherited from interface org.vaadin.miki.markers.WithLabelMixin
withLabel
-
Methods inherited from interface org.vaadin.miki.markers.WithLabelPositionableMixin
withLabelPosition
-
Methods inherited from interface org.vaadin.miki.markers.WithValueMixin
withValue
-
-
-
-
Field Detail
-
DEFAULT_LAYOUT_PROVIDER
public static final com.vaadin.flow.function.SerializableSupplier<com.vaadin.flow.component.orderedlayout.FlexLayout> DEFAULT_LAYOUT_PROVIDER
-
DEFAULT_PROPERTY_PROVIDER
public static final com.vaadin.flow.function.SerializableSupplier<PropertyProvider> DEFAULT_PROPERTY_PROVIDER
-
DEFAULT_COMPONENT_BUILDER
public static final com.vaadin.flow.function.SerializableSupplier<PropertyComponentBuilder> DEFAULT_COMPONENT_BUILDER
-
DEFAULT_GROUPING_PROVIDER
public static final com.vaadin.flow.function.SerializableSupplier<PropertyGroupingProvider> DEFAULT_GROUPING_PROVIDER
-
DEFAULT_GROUP_LAYOUT_PROVIDER
public static final com.vaadin.flow.function.SerializableSupplier<PropertyGroupLayoutProvider> DEFAULT_GROUP_LAYOUT_PROVIDER
-
-
Constructor Detail
-
ObjectField
public ObjectField(Class<T> dataType, com.vaadin.flow.function.SerializableSupplier<T> emptyObjectSupplier)
Builds anObjectFieldusingDEFAULT_LAYOUT_PROVIDERfor the main layout.- Parameters:
dataType- Type of objects to display.emptyObjectSupplier- A method to provide new, empty objects of the given type.
-
ObjectField
public ObjectField(Class<T> dataType, com.vaadin.flow.function.SerializableSupplier<T> emptyObjectSupplier, com.vaadin.flow.function.SerializableSupplier<L> layoutSupplier)
Builds anObjectFieldusing a given supplier for the main layout.- Type Parameters:
L- Layout type.- Parameters:
dataType- Type of objects to display.emptyObjectSupplier- A method to provide new, empty objects of the given type.layoutSupplier- A method to provide the main layout of this component.
-
-
Method Detail
-
generateModelValue
protected T generateModelValue()
- Specified by:
generateModelValuein classcom.vaadin.flow.component.customfield.CustomField<T>
-
repaint
public void repaint()
Repaints the component with its current value. In some rare cases it makes sense to completely reload the components without changing the value of this field.
-
setPresentationValue
protected void setPresentationValue(T t)
- Specified by:
setPresentationValuein classcom.vaadin.flow.component.customfield.CustomField<T>
-
getDataType
public Class<T> getDataType()
Returns the type of the value returned by this field.- Returns:
- Type.
-
markReloadNeeded
protected void markReloadNeeded()
Indicates that reload of data and components is needed.
-
isReloadNeeded
protected boolean isReloadNeeded()
Checks if reloading is currently needed.- Returns:
- When
true, the inner state of the component will be reloaded the next time a value is displayed.
-
getPropertyProvider
public PropertyProvider getPropertyProvider()
Returns the currentPropertyProvider.- Returns:
- Current
PropertyProvider.
-
setPropertyProvider
public void setPropertyProvider(PropertyProvider propertyProvider)
Sets the newPropertyProvider. Note that changes will not be reflected until the component isrepaint()ed or a new value is set.- Parameters:
propertyProvider- APropertyProviderto use. Ifnullis passed, one provided byDEFAULT_PROPERTY_PROVIDERwill be used.
-
withPropertyProvider
public final ObjectField<T> withPropertyProvider(PropertyProvider provider)
ChainssetPropertyProvider(PropertyProvider)and returns itself.- Parameters:
provider- APropertyProviderto use.- Returns:
- This.
- See Also:
setPropertyProvider(PropertyProvider)
-
setPropertyComponentBuilder
public void setPropertyComponentBuilder(PropertyComponentBuilder builder)
Sets the newPropertyComponentBuilder. Note that changes will not be reflected until the component isrepaint()ed or a new value is set.- Parameters:
builder- APropertyComponentBuilderto use. Ifnullis passed, one provided byDEFAULT_COMPONENT_BUILDERwill be used.
-
getPropertyComponentBuilder
public PropertyComponentBuilder getPropertyComponentBuilder()
Returns the currentPropertyComponentBuilder.- Returns:
- A
PropertyComponentBuilder.
-
withPropertyComponentBuilder
public final ObjectField<T> withPropertyComponentBuilder(PropertyComponentBuilder builder)
ChainssetPropertyComponentBuilder(PropertyComponentBuilder)and returns itself.- Parameters:
builder- Builder.- Returns:
- This.
- See Also:
setPropertyComponentBuilder(PropertyComponentBuilder)
-
setPropertyGroupingProvider
public void setPropertyGroupingProvider(PropertyGroupingProvider propertyGroupingProvider)
Sets the newPropertyGroupingProvider. Note that changes will not be reflected until the component isrepaint()ed or a new value is set.- Parameters:
propertyGroupingProvider- APropertyGroupingProviderto use. Ifnullis passed, one provided byDEFAULT_GROUPING_PROVIDERwill be used.
-
getPropertyGroupingProvider
public PropertyGroupingProvider getPropertyGroupingProvider()
Returns the currentPropertyGroupingProvider.- Returns:
- A
PropertyGroupingProvider.
-
withPropertyGroupingProvider
public final ObjectField<T> withPropertyGroupingProvider(PropertyGroupingProvider provider)
ChainssetPropertyGroupingProvider(PropertyGroupingProvider)and returns itself.- Parameters:
provider- Provider.- Returns:
- This.
- See Also:
setPropertyGroupingProvider(PropertyGroupingProvider)
-
getGroupLayoutProvider
public PropertyGroupLayoutProvider getGroupLayoutProvider()
Returns currentPropertyGroupLayoutProvider.- Returns:
- A
PropertyGroupLayoutProvider.
-
setGroupLayoutProvider
public void setGroupLayoutProvider(PropertyGroupLayoutProvider groupLayoutProvider)
Sets the newPropertyGroupLayoutProvider. Note that changes will not be reflected until the component isrepaint()ed or a new value is set.- Parameters:
groupLayoutProvider- APropertyGroupLayoutProviderto use. Ifnullis passed, one provided byDEFAULT_GROUP_LAYOUT_PROVIDERwill be used.
-
withGroupLayoutProvider
public final ObjectField<T> withGroupLayoutProvider(PropertyGroupLayoutProvider provider)
ChainssetGroupLayoutProvider(PropertyGroupLayoutProvider)and returns itself.- Parameters:
provider- Provider.- Returns:
- This.
- See Also:
setGroupLayoutProvider(PropertyGroupLayoutProvider)
-
addComponentConfigurators
@SafeVarargs public final void addComponentConfigurators(ComponentConfigurator<T>... configurators)
Adds givenComponentConfigurators. Each configurator receives every component for each property. Configurators are run in the order of adding. Note that changes will not be reflected until the component isrepaint()ed or a new value is set.- Parameters:
configurators- Configurators to add.
-
addComponentConfigurators
public void addComponentConfigurators(Collection<ComponentConfigurator<T>> configurators)
Adds givenComponentConfigurators. Each configurator receives every component for each property. Configurators are run in the order of adding. Note that changes will not be reflected until the component isrepaint()ed or a new value is set.- Parameters:
configurators- Configurators to add.
-
removeComponentConfigurator
public void removeComponentConfigurator(ComponentConfigurator<T> configurator)
Removes given configurator.- Parameters:
configurator- Configurator to remove.
-
withComponentConfigurators
@SafeVarargs public final ObjectField<T> withComponentConfigurators(ComponentConfigurator<T>... configurators)
ChainsaddComponentConfigurators(ComponentConfigurator[])and returns itself.- Parameters:
configurators- Configurators to add.- Returns:
- This.
- See Also:
addComponentConfigurators(ComponentConfigurator[])
-
withComponentConfigurators
public final ObjectField<T> withComponentConfigurators(Collection<ComponentConfigurator<T>> configurators)
ChainsaddComponentConfigurators(Collection)and returns itself.- Parameters:
configurators- Configurators to add.- Returns:
- This.
- See Also:
addComponentConfigurators(Collection)
-
clearComponentConfigurators
public void clearComponentConfigurators()
Removes all previously addedComponentConfigurator. Note that changes will not be reflected until the component isrepaint()ed or a new value is set.
-
addComponentGroupConfigurators
public void addComponentGroupConfigurators(ComponentGroupConfigurator... configurators)
Adds givenComponentGroupConfigurators. Each configurator receives every group of components after basicComponentConfigurators are executed. Configurators are run in the order of adding. Note that changes will not be reflected until the component isrepaint()ed or a new value is set.- Parameters:
configurators- Configurators to add.
-
addComponentGroupConfigurators
public void addComponentGroupConfigurators(Collection<ComponentGroupConfigurator> configurators)
Adds givenComponentGroupConfigurators. Each configurator receives every group of components after basicComponentConfigurators are executed. Configurators are run in the order of adding. Note that changes will not be reflected until the component isrepaint()ed or a new value is set.- Parameters:
configurators- Configurators to add.
-
removeComponentGroupConfigurator
public void removeComponentGroupConfigurator(ComponentGroupConfigurator configurator)
Removes givenComponentGroupConfigurator. Note that changes will not be reflected until the component isrepaint()ed or a new value is set.- Parameters:
configurator- Configurator to remove.
-
withComponentGroupConfigurators
public final ObjectField<T> withComponentGroupConfigurators(ComponentGroupConfigurator... configurators)
ChainsaddComponentGroupConfigurators(ComponentGroupConfigurator...)and returns itself.- Parameters:
configurators- Configurators to add.- Returns:
- This.
- See Also:
addComponentGroupConfigurators(ComponentGroupConfigurator...)
-
withComponentGroupConfigurators
public final ObjectField<T> withComponentGroupConfigurators(Collection<ComponentGroupConfigurator> configurators)
ChainsaddComponentGroupConfigurators(Collection)and returns itself.- Parameters:
configurators- Configurators to add.- Returns:
- This.
- See Also:
addComponentGroupConfigurators(Collection)
-
clearComponentGroupConfigurators
public void clearComponentGroupConfigurators()
Removes all previously addedComponentGroupConfigurators. Note that changes will not be reflected until the component isrepaint()ed or a new value is set.
-
setReadOnly
public void setReadOnly(boolean readOnly)
- Specified by:
setReadOnlyin interfacecom.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.customfield.CustomField<T>,T>,T>- Specified by:
setReadOnlyin interfacecom.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.customfield.CustomField<T>,T>,T>
-
focus
public void focus()
- Specified by:
focusin interfacecom.vaadin.flow.component.Focusable<T>
-
-