Class StandardEditor<T>

java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.Composite<T>
All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier, com.vaadin.flow.component.DetachNotifier, com.vaadin.flow.component.HasElement, com.vaadin.flow.router.AfterNavigationObserver, com.vaadin.flow.router.BeforeEnterObserver, com.vaadin.flow.router.BeforeLeaveObserver, com.vaadin.flow.router.internal.AfterNavigationHandler, com.vaadin.flow.router.internal.BeforeEnterHandler, com.vaadin.flow.router.internal.BeforeLeaveHandler, ChangeTracker, EditorScreen<T>, ReadOnlyAwareScreen, Serializable

public class StandardEditor<T> extends StandardScreen implements EditorScreen<T>, ReadOnlyAwareScreen
See Also:
  • Field Details

    • NEW_ENTITY_ID

      public static final String NEW_ENTITY_ID
      See Also:
    • showSaveNotification

      protected boolean showSaveNotification
    • commitActionPerformed

      protected boolean commitActionPerformed
  • Constructor Details

    • StandardEditor

      public StandardEditor()
  • Method Details

    • setupModifiedTracking

      protected void setupModifiedTracking()
    • onChangeEvent

      protected void onChangeEvent(DataContext.ChangeEvent changeEvent)
    • onPostCommitEvent

      protected void onPostCommitEvent(DataContext.PostCommitEvent postCommitEvent)
    • getSaveNotificationText

      protected String getSaveNotificationText()
    • beforeEnter

      public void beforeEnter(com.vaadin.flow.router.BeforeEnterEvent event)
      Specified by:
      beforeEnter in interface com.vaadin.flow.router.internal.BeforeEnterHandler
      Overrides:
      beforeEnter in class Screen<ScreenLayout>
    • findEntityId

      protected void findEntityId(com.vaadin.flow.router.BeforeEnterEvent event)
    • commitChanges

      protected OperationResult commitChanges()
    • validateScreen

      protected ValidationErrors validateScreen()
    • validateUiComponents

      protected ValidationErrors validateUiComponents()
    • validateAdditionalRules

      protected ValidationErrors validateAdditionalRules()
    • isCommitActionPerformed

      protected boolean isCommitActionPerformed()
    • commit

      public OperationResult commit()
      Specified by:
      commit in interface EditorScreen<T>
    • closeWithCommit

      public OperationResult closeWithCommit()
      Specified by:
      closeWithCommit in interface EditorScreen<T>
    • closeWithDiscard

      public OperationResult closeWithDiscard()
      Specified by:
      closeWithDiscard in interface EditorScreen<T>
    • isShowSaveNotification

      public boolean isShowSaveNotification()
      Returns:
      whether a notification will be shown in case of successful commit
    • setShowSaveNotification

      public void setShowSaveNotification(boolean showSaveNotification)
      Sets whether a notification will be shown in case of successful commit.
      Parameters:
      showSaveNotification - true if a notification needs to be shown, false otherwise
    • isShowValidationErrors

      public boolean isShowValidationErrors()
      Returns:
      whether to indicate about errors after components validation
    • setShowValidationErrors

      public void setShowValidationErrors(boolean showValidationErrors)
      Sets whether to indicate about errors after components validation. The default value is true.
      Parameters:
      showValidationErrors - true if notification needs to be shown, false otherwise
    • isCrossFieldValidationEnabled

      public boolean isCrossFieldValidationEnabled()
      Returns:
      true if cross-field validation is enabled
    • setCrossFieldValidationEnabled

      public void setCrossFieldValidationEnabled(boolean crossFieldValidationEnabled)
      Sets whether cross-field validation should be performed before commit changes. It uses UiCrossFieldChecks constraint group to validate bean instance. The default value is true.
      Parameters:
      crossFieldValidationEnabled - true if cross-field should be enabled, false otherwise
    • isReadOnly

      public boolean isReadOnly()
      Specified by:
      isReadOnly in interface ReadOnlyAwareScreen
      Returns:
      whether a screen controller in read-only mode.
    • setReadOnly

      public void setReadOnly(boolean readOnly)
      Description copied from interface: ReadOnlyAwareScreen
      Changes the read-only mode.
      Specified by:
      setReadOnly in interface ReadOnlyAwareScreen
      Parameters:
      readOnly - true to enable the read-only mode, false otherwise
    • preventUnsavedChanges

      protected void preventUnsavedChanges(Screen.BeforeCloseEvent event)
    • hasUnsavedChanges

      public boolean hasUnsavedChanges()
      Specified by:
      hasUnsavedChanges in interface ChangeTracker
      Returns:
      true if screen has unsaved changes
    • getEditedEntityContainer

      protected InstanceContainer<T> getEditedEntityContainer()
    • getEditedEntityLoader

      protected InstanceLoader<T> getEditedEntityLoader()
    • getEditedEntity

      public T getEditedEntity()
      Specified by:
      getEditedEntity in interface EditorScreen<T>
      Returns:
      currently edited entity instance
    • setEntityToEdit

      public void setEntityToEdit(T entity)
      Description copied from interface: EditorScreen
      Sets entity instance to editor.
      Specified by:
      setEntityToEdit in interface EditorScreen<T>
      Parameters:
      entity - entity
    • setupEntityToEdit

      protected void setupEntityToEdit()
    • setupEntityToEdit

      protected void setupEntityToEdit(String serializedEntityId)
    • initNewEntity

      protected void initNewEntity(Class<T> entityClass)
    • initExistingEntity

      protected void initExistingEntity(String serializedEntityId)
    • setupEntityToEdit

      protected void setupEntityToEdit(T entityToEdit)
    • doNotReloadEditedEntity

      protected boolean doNotReloadEditedEntity()
    • isEntityModifiedInParentContext

      protected boolean isEntityModifiedInParentContext()
    • isEntityModifiedRecursive

      protected boolean isEntityModifiedRecursive(Object entity, DataContext dataContext, HashSet<Object> visited)
    • setupLock

      protected void setupLock()
    • releaseLock

      protected void releaseLock()
    • getPessimisticLockStatus

      public PessimisticLockStatus getPessimisticLockStatus()
      Specified by:
      getPessimisticLockStatus in interface EditorScreen<T>
      Returns:
      lock status of currently edited entity instance. Possible variants:
      See Also:
    • isReadOnlyDueToLock

      protected boolean isReadOnlyDueToLock()
      Returns:
      true if the editor switched to read-only mode because the entity is locked by another user
    • isLocked

      protected boolean isLocked()
      Returns:
      true if the entity instance has been pessimistically locked when the screen is opened
    • setModifiedAfterOpen

      protected void setModifiedAfterOpen(boolean entityModified)
    • isModifiedAfterOpen

      protected boolean isModifiedAfterOpen()
      Returns:
      true if data is modified after screen opening
    • addInitEntityListener

      protected com.vaadin.flow.shared.Registration addInitEntityListener(com.vaadin.flow.component.ComponentEventListener<StandardEditor.InitEntityEvent<T>> listener)
    • addBeforeCommitChangesListener

      protected com.vaadin.flow.shared.Registration addBeforeCommitChangesListener(com.vaadin.flow.component.ComponentEventListener<StandardEditor.BeforeCommitChangesEvent> listener)
    • addAfterCommitChangesListener

      protected com.vaadin.flow.shared.Registration addAfterCommitChangesListener(com.vaadin.flow.component.ComponentEventListener<StandardEditor.AfterCommitChangesEvent> listener)