Class BeanValidationForm<T>
- All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier
,com.vaadin.flow.component.DetachNotifier
,com.vaadin.flow.component.HasElement
,com.vaadin.flow.component.HasStyle
,Serializable
This version uses FormBinder (published in Viritin 2.8) instead of the basic Vaadin Binder. This might already be better, but most likely there are regressions and edge case that may be incompatible with the old AbstractForm, thus bringing in this with a different name for testing. Once tested enough and if no big regressions, AbstractForm becomes this and possible a backwards compatibility version is created for "core Binder version".
In the default configuration BeanValidationForm expects that fields are lazily pushing their value change events to the server. This way it can automatically adjust e.g. save/cancel buttons based on the state/validity. Either use Viritin fields like VTextField or configure e.g. with setValueChangeMode.
- Author:
- mstahv
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Deprecated.A handler called when the built-in delete button of the form is called.static interface
Deprecated.A handler called when the built-in reset/cancel button of the form is called.static interface
Deprecated.A handler called when the built-in save button of the form is called. -
Constructor Summary
ConstructorDescriptionBeanValidationForm
(Class<T> entityType) Deprecated.Constructor for the abstract form. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Deprecated.Adjusts the reset button state.protected void
Deprecated.Adjust save button state.protected void
bind()
Deprecated.void
Deprecated.protected com.vaadin.flow.component.Component
Deprecated.This method should return the actual content of the form, including possible toolbar.protected com.vaadin.flow.component.button.Button
Deprecated.protected com.vaadin.flow.component.button.Button
Deprecated.protected com.vaadin.flow.component.button.Button
Deprecated.protected void
delete
(com.vaadin.flow.component.ClickEvent<com.vaadin.flow.component.button.Button> e) Deprecated.protected <T> Set<jakarta.validation.ConstraintViolation<T>>
doBeanValidation
(T object) Deprecated.void
Deprecated.Focuses the first field found from the form.Deprecated.Deprecated.com.vaadin.flow.component.button.Button
Deprecated.Deprecated.Deprecated.Deprecated.protected abstract List<com.vaadin.flow.component.Component>
Deprecated.Return the list of field components added to the form body by default.Deprecated.com.vaadin.flow.component.dialog.Dialog
getPopup()
Deprecated.com.vaadin.flow.component.button.Button
Deprecated.Deprecated.com.vaadin.flow.component.button.Button
Deprecated.Deprecated.Deprecated.com.vaadin.flow.component.orderedlayout.HorizontalLayout
Deprecated.Class<?>[]
Deprecated.protected jakarta.validation.Validator
Deprecated.boolean
Deprecated.protected boolean
isBound()
Deprecated.boolean
isValid()
Deprecated.protected void
lazyInit()
Deprecated.Deprecated.protected void
reset
(com.vaadin.flow.component.ClickEvent<com.vaadin.flow.component.button.Button> e) Deprecated.protected void
save
(com.vaadin.flow.component.ClickEvent<com.vaadin.flow.component.button.Button> e) Deprecated.void
setCancelCaption
(String cancelCaption) Deprecated.void
setDeleteButton
(com.vaadin.flow.component.button.Button deleteButton) Deprecated.void
setDeleteCaption
(String deleteCaption) Deprecated.void
setDeleteHandler
(BeanValidationForm.DeleteHandler<T> deleteHandler) Deprecated.void
Deprecated.Sets the object to be edited by this form.void
setEntityWithEnabledSave
(T entity) Deprecated.by default only save button get's enabled when form has any changes
you can use this method in case the prefilled entity is already valid and save should be possible to press without any changes
if entity is not valid saveButton will stay disabled!protected void
setHasChanges
(boolean hasChanges) Deprecated.void
setModalWindowTitle
(String modalWindowTitle) Deprecated.void
setResetButton
(com.vaadin.flow.component.button.Button resetButton) Deprecated.void
setResetHandler
(BeanValidationForm.ResetHandler<T> resetHandler) Deprecated.void
setSaveButton
(com.vaadin.flow.component.button.Button button) Deprecated.void
setSaveCaption
(String saveCaption) Deprecated.void
setSavedHandler
(BeanValidationForm.SavedHandler<T> savedHandler) Deprecated.void
setValidationGroups
(Class<?>... groups) Deprecated.Methods inherited from class com.vaadin.flow.component.Composite
getChildren, getContent, getElement, initContent
Methods inherited from class com.vaadin.flow.component.Component
addListener, findAncestor, fireEvent, from, get, 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, 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.AttachNotifier
addAttachListener
Methods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListener
Methods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
-
Constructor Details
-
BeanValidationForm
Deprecated.Constructor for the abstract form.- Parameters:
entityType
- The class type used for data binding
-
-
Method Details
-
setEntityWithEnabledSave
Deprecated.by default only save button get's enabled when form has any changes
you can use this method in case the prefilled entity is already valid and save should be possible to press without any changes
if entity is not valid saveButton will stay disabled!- Parameters:
entity
- the object to be edited by this form
-
hasChanges
public boolean hasChanges()Deprecated.- Returns:
- true if bean has been changed since last setEntity call.
-
setHasChanges
protected void setHasChanges(boolean hasChanges) Deprecated. -
isValid
Deprecated. -
getResetHandler
Deprecated. -
setResetHandler
Deprecated. -
getSavedHandler
Deprecated. -
setSavedHandler
Deprecated. -
getDeleteHandler
Deprecated. -
setDeleteHandler
Deprecated. -
getSaveCaption
Deprecated. -
setSaveCaption
Deprecated. -
getModalWindowTitle
Deprecated. -
setModalWindowTitle
Deprecated. -
getDeleteCaption
Deprecated. -
setDeleteCaption
Deprecated. -
getCancelCaption
Deprecated. -
setCancelCaption
Deprecated. -
getBinder
Deprecated. -
lazyInit
protected void lazyInit()Deprecated. -
bind
protected void bind()Deprecated. -
getValidationGroups
Deprecated. -
setValidationGroups
Deprecated. -
doBeanValidation
Deprecated. -
getValidator
protected jakarta.validation.Validator getValidator()Deprecated. -
createContent
protected com.vaadin.flow.component.Component createContent()Deprecated.This method should return the actual content of the form, including possible toolbar.Use setEntity(T entity) to fill in the data. Am example implementation could look like this:
public class PersonForm extends AbstractForm<Person> { private TextField firstName = new MTextField("First Name"); private TextField lastName = new MTextField("Last Name"); @Override protected Component createContent() { return new MVerticalLayout( new FormLayout( firstName, lastName ), getToolbar() ); } }
- Returns:
- the content of the form
-
getFormComponents
Deprecated.Return the list of field components added to the form body by default. Use a dummy implementation if your override createContent() method where you can fully customise how the content of the form is built.- Returns:
- the fields displayed in the form created by createContent() method.
-
adjustSaveButtonState
protected void adjustSaveButtonState()Deprecated.Adjust save button state. Override if you for example want to have Save button always enabled, even if the Binder has not tracked any changes yet. -
getSaveButton
public com.vaadin.flow.component.button.Button getSaveButton()Deprecated. -
setSaveButton
public void setSaveButton(com.vaadin.flow.component.button.Button button) Deprecated. -
createSaveButton
protected com.vaadin.flow.component.button.Button createSaveButton()Deprecated. -
isBound
protected boolean isBound()Deprecated. -
createResetButton
protected com.vaadin.flow.component.button.Button createResetButton()Deprecated. -
getResetButton
public com.vaadin.flow.component.button.Button getResetButton()Deprecated. -
setResetButton
public void setResetButton(com.vaadin.flow.component.button.Button resetButton) Deprecated. -
createDeleteButton
protected com.vaadin.flow.component.button.Button createDeleteButton()Deprecated. -
getDeleteButton
public com.vaadin.flow.component.button.Button getDeleteButton()Deprecated. -
setDeleteButton
public void setDeleteButton(com.vaadin.flow.component.button.Button deleteButton) Deprecated. -
adjustResetButtonState
protected void adjustResetButtonState()Deprecated.Adjusts the reset button state. Override if you for example wish to keep reset/cancel button enabled even if there is nothing to reset. -
getEntity
Deprecated.- Returns:
- the currently edited entity or null if the form is currently unbound
-
setEntity
Deprecated.Sets the object to be edited by this form. This method binds all fields from this form to given objects.If your form needs to manually configure something based on the state of the edited object, you can override this method to do that either before the object is bound to fields or to do something after the bean binding.
- Parameters:
entity
- the object to be edited by this form
-
save
protected void save(com.vaadin.flow.component.ClickEvent<com.vaadin.flow.component.button.Button> e) Deprecated. -
reset
protected void reset(com.vaadin.flow.component.ClickEvent<com.vaadin.flow.component.button.Button> e) Deprecated. -
delete
protected void delete(com.vaadin.flow.component.ClickEvent<com.vaadin.flow.component.button.Button> e) Deprecated. -
getToolbar
public com.vaadin.flow.component.orderedlayout.HorizontalLayout getToolbar()Deprecated.- Returns:
- A default toolbar containing save/cancel/delete buttons
-
openInModalPopup
Deprecated. -
focusFirst
public void focusFirst()Deprecated.Focuses the first field found from the form. It often improves UX to call this method, or focus another field, when you assign a bean for editing. -
getPopup
public com.vaadin.flow.component.dialog.Dialog getPopup()Deprecated.- Returns:
- the last Popup into which the Form was opened with #openInModalPopup method or null if the form hasn't been use in window
-
closePopup
public void closePopup()Deprecated.
-