Package com.storedobject.ui
Class ObjectFormField<T extends StoredObject>
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>
com.storedobject.ui.ObjectFormField<T>
- All Implemented Interfaces:
FilterMethods<T>,ObjectGetter<T>,ObjectSetter<T>,ObjectInput<T>,ObjectProvider<T>,AbstractObjectInput<T>,NoDisplayField,HasElement,HasThemeStyle,ValueRequired,ViewDependent,com.vaadin.flow.component.AttachNotifier,com.vaadin.flow.component.BlurNotifier<com.vaadin.flow.component.customfield.CustomField<T>>,com.vaadin.flow.component.DetachNotifier,com.vaadin.flow.component.Focusable<com.vaadin.flow.component.customfield.CustomField<T>>,com.vaadin.flow.component.FocusNotifier<com.vaadin.flow.component.customfield.CustomField<T>>,com.vaadin.flow.component.HasElement,com.vaadin.flow.component.HasEnabled,com.vaadin.flow.component.HasHelper,com.vaadin.flow.component.HasLabel,com.vaadin.flow.component.HasPlaceholder,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,com.vaadin.flow.component.shared.HasValidationProperties,com.vaadin.flow.component.shared.InputField<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.customfield.CustomField<T>,,T>, T> Serializable,Consumer<T>
public class ObjectFormField<T extends StoredObject>
extends com.vaadin.flow.component.customfield.CustomField<T>
implements ObjectInput<T>, ViewDependent, NoDisplayField, ValueRequired
- See Also:
-
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> 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>, com.vaadin.flow.component.HasValue.ValueChangeListener<E extends com.vaadin.flow.component.HasValue.ValueChangeEvent<?>> -
Constructor Summary
ConstructorsConstructorDescriptionObjectFormField(ObjectEditor<T> formEditor) ObjectFormField(ObjectEditor<T> formEditor, ObjectField.Type formType) ObjectFormField(ObjectEditor<T> formEditor, HasContainer mergeTo) ObjectFormField(Class<T> objectClass) ObjectFormField(Class<T> objectClass, ObjectField.Type formType) ObjectFormField(Class<T> objectClass, HasContainer mergeTo) ObjectFormField(String label, ObjectEditor<T> formEditor) ObjectFormField(String label, ObjectEditor<T> formEditor, ObjectField.Type formType) ObjectFormField(String label, ObjectEditor<T> formEditor, HasContainer mergeTo) ObjectFormField(String label, Class<T> objectClass) ObjectFormField(String label, Class<T> objectClass, ObjectField.Type formType) ObjectFormField(String label, Class<T> objectClass, HasContainer mergeTo) ObjectFormField(String label, Class<T> objectClass, String fieldName, BiFunction<String, Class<T>, ObjectEditor<T>> editorCreator, ObjectField.Type formType) ObjectFormField(String label, Class<T> objectClass, String fieldName, BiFunction<String, Class<T>, ObjectEditor<T>> editorCreator, HasContainer mergeTo) -
Method Summary
Modifier and TypeMethodDescriptionvoidThis method is called whenever a filter condition is changed.voidattach()Attach this to the respective container.booleanCan this field display information like normal fields?voidclear()Clear the field value.voidfocus()Focus this field.protected TGet the currently cached object.Get the dependent view.com.vaadin.flow.component.ComponentGet the component that is currently displaying details of the object value.Get the consumer that is currently consuming details of the object value.final ObjectEditor<T> Get the internal label of this field.Get the load filter.Get the current object.Get the object for the givenId.Class of the object supported in this input field.Get theIdof the current object.getObjectId(T object) Get theIdof the given object.getValue()Get the current value.booleanbooleanGet the value required flag.voidload(ObjectIterator<T> objects) This method does nothing in this field.voidreload()Reload the allowed values by applying newly set filters.voidsetDependentView(View masterView) Set the dependent view.voidsetDetailComponent(com.vaadin.flow.component.Component detailComponent) Set a component that will display details of the object value.voidsetDisplayDetail(Consumer<T> displayDetail) Set a consumer that can display/consume the details of the object value.voidsetEnabled(boolean enabled) Enable/disable this field.voidsetInternalLabel(String label) Set the internal label for this field.voidSet object for the givenId.voidsetObject(StoredObject object) Set the given object as the value.final voidsetObjectClass(Class<? extends T>... classes) Set one or more (typically more than one) class subtypes that this field should allow.voidsetPlaceholder(String placeholder) voidsetPrefixFieldControl(boolean prefixFieldControl) Decide whether "prefix components" needs to be controlled by this field or not.protected voidsetPresentationValue(T object) voidsetReadOnly(boolean readOnly) Make this field read-only.voidsetRequired(boolean required) Set value required flag.voidSet the value as anId.voidSet the value.protected voidprotected booleanvalueEquals(T value1, T value2) Methods inherited from class com.vaadin.flow.component.customfield.CustomField
add, addThemeVariants, getLabel, remove, removeThemeVariants, setLabelMethods inherited from class com.vaadin.flow.component.AbstractField
addValueChangeListener, getEmptyValue, isEmpty, setModelValueMethods 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, setVisibleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.storedobject.ui.util.AbstractObjectInput
applyFilterPredicate, convert, isAllowAny, setCached, setItemLabelGeneratorMethods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListenerMethods inherited from interface com.vaadin.flow.component.BlurNotifier
addBlurListenerMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.storedobject.core.FilterMethods
getEffectiveCondition, getFilterCondition, setFilter, setFilter, setFilter, setFilter, setFilter, setFilter, setLoadFilter, setLoadFilter, setViewFilter, setViewFilterMethods inherited from interface com.vaadin.flow.component.Focusable
addFocusShortcut, blur, getTabIndex, setTabIndexMethods inherited from interface com.vaadin.flow.component.FocusNotifier
addFocusListenerMethods inherited from interface com.storedobject.vaadin.HasElement
getAttribute, getStyle, setAttribute, setStyleMethods inherited from interface com.vaadin.flow.component.HasElement
getElementMethods inherited from interface com.vaadin.flow.component.HasEnabled
isEnabledMethods inherited from interface com.vaadin.flow.component.HasHelper
getHelperComponent, getHelperText, setHelperComponent, setHelperTextMethods inherited from interface com.vaadin.flow.component.HasLabel
getLabel, setLabelMethods inherited from interface com.vaadin.flow.component.HasPlaceholder
getPlaceholderMethods 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, setWidthFullMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassNameMethods inherited from interface com.vaadin.flow.component.HasTheme
addThemeName, addThemeNames, getThemeName, getThemeNames, hasThemeName, removeThemeName, removeThemeNames, setThemeName, setThemeNameMethods inherited from interface com.storedobject.vaadin.HasThemeStyle
addTheme, asPrimary, asSmall, clearThemes, getInternalElement, removeTheme, setThemeMethods inherited from interface com.vaadin.flow.component.shared.HasTooltip
getTooltip, setTooltipTextMethods inherited from interface com.vaadin.flow.component.HasValidation
setManualValidationMethods inherited from interface com.vaadin.flow.component.shared.HasValidationProperties
getErrorMessage, setErrorMessage, setInvalidMethods inherited from interface com.vaadin.flow.component.HasValue
addValueChangeListener, getEmptyValue, getOptionalValue, isEmptyMethods inherited from interface com.vaadin.flow.component.HasValueAndElement
isReadOnly, isRequiredIndicatorVisible, setRequiredIndicatorVisibleMethods inherited from interface com.storedobject.ui.ObjectInput
getSearcherMethods inherited from interface com.storedobject.core.ObjectSetter
accept
-
Constructor Details
-
ObjectFormField
-
ObjectFormField
-
ObjectFormField
-
ObjectFormField
-
ObjectFormField
-
ObjectFormField
-
ObjectFormField
-
ObjectFormField
-
ObjectFormField
-
ObjectFormField
-
ObjectFormField
-
ObjectFormField
-
ObjectFormField
public ObjectFormField(String label, Class<T> objectClass, String fieldName, BiFunction<String, Class<T>, ObjectEditor<T>> editorCreator, ObjectField.Type formType) -
ObjectFormField
public ObjectFormField(String label, Class<T> objectClass, String fieldName, BiFunction<String, Class<T>, ObjectEditor<T>> editorCreator, HasContainer mergeTo)
-
-
Method Details
-
clear
public void clear()Description copied from interface:AbstractObjectInputClear the field value.- Specified by:
clearin interfaceAbstractObjectInput<T extends StoredObject>- Specified by:
clearin interfacecom.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.customfield.CustomField<T extends StoredObject>,T extends StoredObject>, T extends StoredObject>
-
setRequired
public void setRequired(boolean required) Description copied from interface:ValueRequiredSet value required flag.- Specified by:
setRequiredin interfaceValueRequired- Parameters:
required- Required or not
-
isRequired
public boolean isRequired()Description copied from interface:ValueRequiredGet the value required flag.- Specified by:
isRequiredin interfaceValueRequired- Returns:
- Whether required or not.
-
canDisplay
public boolean canDisplay()Description copied from interface:NoDisplayFieldCan this field display information like normal fields?- Specified by:
canDisplayin interfaceNoDisplayField- Returns:
- True/false.
-
updateValue
protected void updateValue()- Overrides:
updateValuein classcom.vaadin.flow.component.customfield.CustomField<T extends StoredObject>
-
generateModelValue
- Specified by:
generateModelValuein classcom.vaadin.flow.component.customfield.CustomField<T extends StoredObject>
-
setPresentationValue
- Specified by:
setPresentationValuein classcom.vaadin.flow.component.customfield.CustomField<T extends StoredObject>
-
valueEquals
- Overrides:
valueEqualsin classcom.vaadin.flow.component.AbstractField<com.vaadin.flow.component.customfield.CustomField<T extends StoredObject>,T extends StoredObject>
-
setDetailComponent
public void setDetailComponent(com.vaadin.flow.component.Component detailComponent) Description copied from interface:AbstractObjectInputSet a component that will display details of the object value.- Specified by:
setDetailComponentin interfaceAbstractObjectInput<T extends StoredObject>- Parameters:
detailComponent- A component that can display information regarding the object.
-
getDetailComponent
public com.vaadin.flow.component.Component getDetailComponent()Description copied from interface:AbstractObjectInputGet the component that is currently displaying details of the object value.- Specified by:
getDetailComponentin interfaceAbstractObjectInput<T extends StoredObject>- Returns:
- Component that is displaying the details.
-
setDisplayDetail
Description copied from interface:AbstractObjectInputSet a consumer that can display/consume the details of the object value.- Specified by:
setDisplayDetailin interfaceAbstractObjectInput<T extends StoredObject>- Parameters:
displayDetail- A consumer that can accept the object value.
-
getDisplayDetail
Description copied from interface:AbstractObjectInputGet the consumer that is currently consuming details of the object value.- Specified by:
getDisplayDetailin interfaceAbstractObjectInput<T extends StoredObject>- Returns:
- Consumer that is currently set.
-
setPrefixFieldControl
public void setPrefixFieldControl(boolean prefixFieldControl) Description copied from interface:AbstractObjectInputDecide whether "prefix components" needs to be controlled by this field or not. "Prefix components" are parts of the field that display extra information, and it needs to be turned on or off when the status of the field changes via methods such asAbstractObjectInput.setEnabled(boolean),AbstractObjectInput.setReadOnly(boolean)etc. In some cases, prefix components may be displayed elsewhere and needs to be controlled outside the field.- Specified by:
setPrefixFieldControlin interfaceAbstractObjectInput<T extends StoredObject>- Parameters:
prefixFieldControl- True if it needs to be controlled by this field.
-
isInvalid
public boolean isInvalid()- Specified by:
isInvalidin interfacecom.vaadin.flow.component.HasValidation- Specified by:
isInvalidin interfacecom.vaadin.flow.component.shared.HasValidationProperties
-
getObjectClass
Description copied from interface:AbstractObjectInputClass of the object supported in this input field.- Specified by:
getObjectClassin interfaceAbstractObjectInput<T extends StoredObject>- Specified by:
getObjectClassin interfaceObjectGetter<T extends StoredObject>- Specified by:
getObjectClassin interfaceObjectProvider<T extends StoredObject>- Specified by:
getObjectClassin interfaceObjectSetter<T extends StoredObject>- Returns:
- Class of the supported object.
-
getObject
Description copied from interface:ObjectInputGet the current object. Same asObjectInput.getValue().- Specified by:
getObjectin interfaceAbstractObjectInput<T extends StoredObject>- Specified by:
getObjectin interfaceObjectGetter<T extends StoredObject>- Specified by:
getObjectin interfaceObjectInput<T extends StoredObject>- Specified by:
getObjectin interfaceObjectProvider<T extends StoredObject>- Returns:
- Current object.
-
setObject
Description copied from interface:ObjectInputSet the given object as the value.- Specified by:
setObjectin interfaceAbstractObjectInput<T extends StoredObject>- Specified by:
setObjectin interfaceObjectInput<T extends StoredObject>- Specified by:
setObjectin interfaceObjectSetter<T extends StoredObject>- Parameters:
object- Object to set.
-
getObjectId
Description copied from interface:AbstractObjectInputGet theIdof the current object.- Specified by:
getObjectIdin interfaceAbstractObjectInput<T extends StoredObject>- Specified by:
getObjectIdin interfaceObjectGetter<T extends StoredObject>- Specified by:
getObjectIdin interfaceObjectProvider<T extends StoredObject>- Returns:
Idornullif no object is currently set.
-
setObject
Description copied from interface:AbstractObjectInputSet object for the givenId.- Specified by:
setObjectin interfaceAbstractObjectInput<T extends StoredObject>- Specified by:
setObjectin interfaceObjectSetter<T extends StoredObject>- Parameters:
objectId-Idof the object to be set.
-
getObject
Description copied from interface:AbstractObjectInputGet the object for the givenId. (This is a helper method.)- Specified by:
getObjectin interfaceAbstractObjectInput<T extends StoredObject>- Parameters:
objectId-Idfor which object needs to be returned.- Returns:
- Object retrieved from the database or cache. It returns
nullif not found.
-
getCached
Description copied from interface:AbstractObjectInputGet the currently cached object.- Specified by:
getCachedin interfaceAbstractObjectInput<T extends StoredObject>- Returns:
- Object that is currently cached. It may return
null.
-
setPlaceholder
- Specified by:
setPlaceholderin interfacecom.vaadin.flow.component.HasPlaceholder
-
getObjectId
Description copied from interface:AbstractObjectInputGet theIdof the given object. (This is a helper method.)- Specified by:
getObjectIdin interfaceAbstractObjectInput<T extends StoredObject>- Parameters:
object- Object for whichIdis required.- Returns:
Idof the object.
-
getValue
Description copied from interface:ObjectInputGet the current value.- Specified by:
getValuein interfacecom.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.customfield.CustomField<T extends StoredObject>,T extends StoredObject>, T extends StoredObject> - Specified by:
getValuein interfaceObjectInput<T extends StoredObject>- Overrides:
getValuein classcom.vaadin.flow.component.AbstractField<com.vaadin.flow.component.customfield.CustomField<T extends StoredObject>,T extends StoredObject> - Returns:
- Value.
-
setInternalLabel
Description copied from interface:ObjectInputSet the internal label for this field. Internal labels are used by the embedded field within this field.- Specified by:
setInternalLabelin interfaceObjectInput<T extends StoredObject>- Parameters:
label- Label.
-
getInternalLabel
Description copied from interface:ObjectInputGet the internal label of this field. Internal labels are used by the embedded field within this field.- Specified by:
getInternalLabelin interfaceObjectInput<T extends StoredObject>- Returns:
- Label.
-
setValue
Description copied from interface:ObjectInputSet the value as anId. The object representing theIdvalue will be set. If the corresponding object value is not compatible,nullvalue will be set.- Specified by:
setValuein interfaceObjectInput<T extends StoredObject>- Parameters:
id-Idof the object to be set.
-
setValue
Description copied from interface:ObjectInputSet the value.- Specified by:
setValuein interfacecom.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.customfield.CustomField<T extends StoredObject>,T extends StoredObject>, T extends StoredObject> - Specified by:
setValuein interfaceObjectInput<T extends StoredObject>- Overrides:
setValuein classcom.vaadin.flow.component.AbstractField<com.vaadin.flow.component.customfield.CustomField<T extends StoredObject>,T extends StoredObject> - Parameters:
object- Value to set.
-
applyFilter
public void applyFilter()Description copied from interface:FilterMethodsThis method is called whenever a filter condition is changed. Methods with default implementation already invoke this method. If any of those methods are overridden, make sure that it invokes this method so that logic to handle filter changes can be coded here.- Specified by:
applyFilterin interfaceFilterMethods<T extends StoredObject>
-
getLoadFilter
Description copied from interface:FilterMethodsGet the load filter.- Specified by:
getLoadFilterin interfaceFilterMethods<T extends StoredObject>- Returns:
- Current load filter.
-
setReadOnly
public void setReadOnly(boolean readOnly) Description copied from interface:AbstractObjectInputMake this field read-only.- Specified by:
setReadOnlyin interfaceAbstractObjectInput<T extends StoredObject>- Specified by:
setReadOnlyin interfacecom.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.customfield.CustomField<T extends StoredObject>,T extends StoredObject>, T extends StoredObject> - Specified by:
setReadOnlyin interfacecom.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.customfield.CustomField<T extends StoredObject>,T extends StoredObject>, T extends StoredObject> - Parameters:
readOnly- True to set as read-only.
-
setEnabled
public void setEnabled(boolean enabled) Description copied from interface:AbstractObjectInputEnable/disable this field.- Specified by:
setEnabledin interfaceAbstractObjectInput<T extends StoredObject>- Specified by:
setEnabledin interfacecom.vaadin.flow.component.HasEnabled- Parameters:
enabled- True for enabling.
-
setDependentView
Description copied from interface:ViewDependentSet the dependent view.- Specified by:
setDependentViewin interfaceViewDependent- Parameters:
masterView- The dependent view.
-
getDependentView
Description copied from interface:ViewDependentGet the dependent view.- Specified by:
getDependentViewin interfaceViewDependent- Returns:
- The dependent view.
-
attach
public void attach()Attach this to the respective container. There is no need to call this method if you are attaching this to anObjectEditor. -
focus
public void focus()Description copied from interface:AbstractObjectInputFocus this field.- Specified by:
focusin interfaceAbstractObjectInput<T extends StoredObject>- Specified by:
focusin interfacecom.vaadin.flow.component.Focusable<T extends StoredObject>
-
load
This method does nothing in this field.- Specified by:
loadin interfaceObjectInput<T extends StoredObject>- Parameters:
objects- Objects to load.
-
reload
public void reload()Description copied from interface:ObjectInputReload the allowed values by applying newly set filters.- Specified by:
reloadin interfaceObjectInput<T extends StoredObject>
-
setObjectClass
Description copied from interface:ObjectInputSet one or more (typically more than one) class subtypes that this field should allow.- Specified by:
setObjectClassin interfaceObjectInput<T extends StoredObject>- Parameters:
classes- Classes to allow.
-
getFormEditor
-