Package com.storedobject.vaadin
Class AbstractDataEditor<T>
java.lang.Object
com.storedobject.vaadin.View
com.storedobject.vaadin.AbstractDataForm<T>
com.storedobject.vaadin.AbstractDataEditor<T>
- Type Parameters:
T- Type of object to be edited
- All Implemented Interfaces:
ClickHandler,ExecutableView,HasContainer,ValueChangeHandler,com.vaadin.flow.component.ComponentEventListener<com.vaadin.flow.component.ClickEvent<? extends com.vaadin.flow.component.Component>>,com.vaadin.flow.component.HasValue.ValueChangeListener,Serializable,Runnable,EventListener
- Direct Known Subclasses:
DataEditor,ObjectEditor
A view that is used for creating "data entry forms" for a particular type of object. The "form" embedded in this
is an
ObjectForm. Please refer to ObjectForm for a detailed explanation of how the "form" is
generated. Many of the methods in this are delegated to the embedded "form".- Author:
- Syam
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classForm to be used internally.Nested classes/interfaces inherited from class com.storedobject.vaadin.AbstractDataForm
AbstractDataForm.FieldErrorNested classes/interfaces inherited from interface com.storedobject.vaadin.ClickHandler
ClickHandler.ModifiedClickEvent<C extends com.vaadin.flow.component.Component> -
Field Summary
Fields inherited from class com.storedobject.vaadin.AbstractDataForm
form -
Constructor Summary
ConstructorsConstructorDescriptionAbstractDataEditor(Class<T> objectClass) ConstructorAbstractDataEditor(Class<T> objectClass, String caption) Constructor -
Method Summary
Modifier and TypeMethodDescriptionprotected <V> StringAdd an extra fieldprotected <V> StringaddField(com.vaadin.flow.component.HasValue<?, V> field, Function<T, V> valueGetter, BiConsumer<T, V> valueSetter) Add an extra fieldprotected voidAdd extra fields.protected voidAdd extra fields.protected voidAdd an extra fieldprotected voidAdd an extra fieldprotected voidAdd an extra fieldprotected voidAdd an extra fieldprotected final com.vaadin.flow.component.HasValue<?, ?> constructField(String fieldName) Construct a field for the given field name.protected com.vaadin.flow.component.HasValue<?, ?> createField(String fieldName, Class<?> fieldType, String label) Create the field for the particular name..protected TCreate an instance of the object.protected voidcustomizeField(String fieldName, com.vaadin.flow.component.HasValue<?, ?> field) Customize a field.Get the class of the object being edited.protected ObjectFieldCreator<T> Get the "field creator" for this form.protected MethodgetFieldGetMethod(String fieldName) Get the field's "get" method.Get the names of the fields to be generated in the form.protected intgetFieldOrder(String fieldName) Get the order in which a field to appear in the form.protected MethodgetFieldSetMethod(String fieldName, Method getMethod) Get the field's "set" method.getForm()Get the form embedded in this view.Get the instance of the currently editing object.Get the class of the object being edited.protected booleanhandleValueSetError(String fieldName, com.vaadin.flow.component.HasValue<?, ?> field, Object fieldValue, Object objectValue, Throwable error) Handle errors while setting (committing) values.protected booleanincludeField(String fieldName) Check whether field should be included in the form or not.final booleanisFieldIncluded(String fieldName) Check whether this field was included while creating this editor or not.final TCreate an instance of the object (public method).voidsetFixedValue(com.vaadin.flow.component.HasValue<?, ?> field, Object value) Set a fixed value for a field.voidsetFixedValue(String fieldName, Object value) Set a fixed value for a field.voidsetFixedValues(T object) Set the attributes of the object with "fixed values" from the respective fields if fixed values are defined usingsetFixedValue(String, Object)orsetFixedValue(HasValue, Object)method for those attributes.voidSet the current object.voidSet the current object.Methods inherited from class com.storedobject.vaadin.AbstractDataForm
add, addConstructedListener, addField, addField, addIncludeFieldChecker, addValidator, addValidator, attachField, clean, clearAlerts, clearError, clearErrors, clearFields, commit, connect, connect, connect, createButtonLayout, createField, createField, createFieldContainer, createLayout, detachField, fieldAttached, fieldDetached, fireFormConstructed, formConstructed, getColumns, getColumnSpan, getContainer, getContent, getData, getErrorDisplay, getField, getFieldLabel, getFieldLabel, getFieldName, getLabel, isFieldEditable, isFieldEditable, isFieldVisible, isFieldVisible, isReadOnly, load, markError, newLine, remove, removeAll, removeField, removeField, removeField, setColumns, setColumnSpan, setErrorDisplay, setFieldContainerProvider, setFieldCustomizer, setFieldEditable, setFieldEditable, setFieldHidden, setFieldHidden, setFieldLabel, setFieldLabel, setFieldReadOnly, setFieldReadOnly, setFieldReadOnly, setFieldReadOnly, setFieldVisible, setFieldVisible, setFieldVisible, setFieldVisible, setIncludeFieldChecker, setReadOnly, setRequired, setRequired, setRequired, setRequired, setRequired, setRequired, setRequired, setRequired, setRequired, streamFieldNamesCreated, streamFieldsCreatedMethods inherited from class com.storedobject.vaadin.View
abort, aborted, addClosedListener, addOpenedListener, close, createCloseableView, createWindow, decorateComponent, execute, execute, execute, executing, focus, focus, focusAny, getApplication, getCaption, getComponent, getCreatedBy, getEmbeddedView, getMenuItem, getMenuItem, getView, initUI, invoke, isFullScreen, isScrollable, isWindowMode, select, setCaption, setComponent, setCreatedBy, setDefaultPadding, setEmbeddedView, setFirstFocus, setFullScreen, setScrollable, setWindowMode, skipFirstFocusMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.storedobject.vaadin.ClickHandler
clicked, doubleClicked, onComponentEvent, rightClickedMethods inherited from interface com.storedobject.vaadin.ExecutableView
clicked, createMenuItem, error, getMenuIconName, getView, isCloseable, isHomeView, log, log, message, returnedFrom, run, setClickable, speak, trackValueChange, tray, valueChanged, warningMethods inherited from interface com.storedobject.vaadin.ValueChangeHandler
valueChanged
-
Constructor Details
-
AbstractDataEditor
-
AbstractDataEditor
-
-
Method Details
-
getForm
Description copied from class:AbstractDataFormGet the form embedded in this view.- Overrides:
getFormin classAbstractDataForm<T>- Returns:
- Form
-
getObjectClass
Get the class of the object being edited. (Same asgetDataClass().- Returns:
- Object's class.
-
getDataClass
Get the class of the object being edited. (Same asgetObjectClass().- Returns:
- Object's class.
-
getFieldNames
Get the names of the fields to be generated in the form. This can be overridden to generate a custom list.- Overrides:
getFieldNamesin classAbstractDataForm<T>- Returns:
- Stream of field names.
-
getFieldGetMethod
-
getFieldSetMethod
Get the field's "set" method. The default implementation checks both availability of setXXX method.- Parameters:
fieldName- Name of the fieldgetMethod- "get" method of this field (determined throughgetFieldGetMethod(String))- Returns:
- Field' "set" method (if method is found, it will returns
null).
-
addField
-
addField
Add extra fields.- Parameters:
fieldNames- Names of the fields to be added
-
addField
protected <V> String addField(com.vaadin.flow.component.HasValue<?, V> field, Function<T, V> valueGetter) Add an extra field- Type Parameters:
V- Value type of the field.- Parameters:
field- Field.valueGetter- Function that determines how to get the value to load the field- Returns:
- A field name will be generated (starting with an underscore character followed by a random number) and returned.
-
addField
protected <V> String addField(com.vaadin.flow.component.HasValue<?, V> field, Function<T, V> valueGetter, BiConsumer<T, V> valueSetter) Add an extra field- Type Parameters:
V- Value type of the field.- Parameters:
field- Field.valueGetter- Function that determines how to get the value to load the fieldvalueSetter- Function that determines how to commit value from the field to the object's instance- Returns:
- A field name will be generated (starting with an underscore character followed by a random number) and returned.
-
addField
-
addField
Add an extra field- Parameters:
fieldName- Name of the field.valueGetter- Function that determines how to get the value to load the fieldvalueSetter- Function that determines how to commit value from the field to the object's instance
-
addField
-
addField
Add an extra field- Parameters:
fieldName- Name of the field.getMethod- Method that determines how to get the value to load the fieldsetMethod- Method that determines how to commit the value from the field to the object's instance
-
includeField
Check whether field should be included in the form or not.- Parameters:
fieldName- Name of the field.- Returns:
- True or false. (Default return value is
true).
-
isFieldIncluded
Check whether this field was included while creating this editor or not.- Parameters:
fieldName- Name of the field.- Returns:
- True or false.
-
customizeField
Customize a field. This method is invoked when a field is created. One may do some customization here.- Parameters:
fieldName- Name of the fieldfield- Field
-
createField
protected com.vaadin.flow.component.HasValue<?,?> createField(String fieldName, Class<?> fieldType, String label) Create the field for the particular name.. Default implementation try to obtain the value from the "field creator" (ObjectFieldCreator.createField(String, Class, String)).- Parameters:
fieldName- Name of the fieldfieldType- Type of the field's valuelabel- Label- Returns:
- Field
-
constructField
Construct a field for the given field name. (For internal purpose only).- Parameters:
fieldName- Field name- Returns:
- Field
-
getFieldCreator
Get the "field creator" for this form. By default, it tries to obtain it fromApplicationEnvironment.getObjectFieldCreator().- Returns:
- Field creator.
-
getFieldOrder
Get the order in which a field to appear in the form. Any integer value can be returned and the field is placed in the form in ascending order of the values returned by this method. Default implementation try to obtain the value from the "field creator" (ObjectFieldCreator.getFieldOrder(String)).- Parameters:
fieldName- Name of the field- Returns:
- Field order.
-
createObjectInstance
Create an instance of the object. Default implementation tries to invoke the default constructor to create an instance and fixed values will be set if defined.- Returns:
- Newly created object.
-
newObject
Create an instance of the object (public method).- Returns:
- Newly created object.
-
getObject
Get the instance of the currently editing object. (A new object will be created by invokingcreateObjectInstance()if there is no current object instance set).- Returns:
- Instance of the currently loaded object.
-
setObject
Set the current object. Fields will be loaded.- Parameters:
object- Object to set
-
setObject
Set the current object. Fields will be loaded.- Parameters:
object- Object to setload- Whether to load the fields or not
-
setFixedValue
Set a fixed value for a field. If a fixed value is set, that value will be set to the corresponding attribute of the object when a new instance is created. (The field value may be still overwritten).- Parameters:
fieldName- Name of the fieldvalue- Value to be set as fixed value
-
setFixedValue
Set a fixed value for a field. If a fixed value is set, that value will be set to the corresponding attribute of the object when a new instance is created. (The field value may be still overwritten).- Parameters:
field- Fieldvalue- Value to be set as fixed value
-
setFixedValues
Set the attributes of the object with "fixed values" from the respective fields if fixed values are defined usingsetFixedValue(String, Object)orsetFixedValue(HasValue, Object)method for those attributes.- Parameters:
object- Object to which fixed values to be set.
-
handleValueSetError
protected boolean handleValueSetError(String fieldName, com.vaadin.flow.component.HasValue<?, ?> field, Object fieldValue, Object objectValue, Throwable error) Handle errors while setting (committing) values. Default implementation returnstruewithout doing anything.- Parameters:
fieldName- Name of the fieldfield- FieldfieldValue- Field's value that's being committedobjectValue- Value currently being in the objecterror- Error occurred while setting the value- Returns:
- Whether the error situation is handled or not.
-