Class View.BeforeCloseEvent

java.lang.Object
java.util.EventObject
com.vaadin.flow.component.ComponentEvent<View<?>>
io.jmix.flowui.view.View.BeforeCloseEvent
All Implemented Interfaces:
Serializable
Enclosing class:
View<T extends com.vaadin.flow.component.Component>

public static class View.BeforeCloseEvent extends com.vaadin.flow.component.ComponentEvent<View<?>>
The first event in the view closing process. The view is still displayed and fully functional.

In this event listener, you can check any conditions and prevent closing using the preventClose() method of the event, for example:

     @Subscribe
     protected void onBeforeClose(BeforeCloseEvent event) {
         if (Strings.isNullOrEmpty(textField.getTypedValue())) {
             notifications.show("Input required");
             event.preventClose();
         }
     }
 

Note the event can be triggered few times for one View instance. It may happen if the user tries to navigate to the same View, which is currently opened. In this case, View.BeforeCloseEvent is triggered, because we "close" the View, however due to navigation the same instance of View will be opened. It means View.BeforeCloseEvent will be triggered again for the same View instance, when user close the View or navigates to another one.

See Also:
  • Field Details

    • closeAction

      protected final CloseAction closeAction
    • closeResult

      protected OperationResult closeResult
    • closePrevented

      protected boolean closePrevented
  • Constructor Details

    • BeforeCloseEvent

      public BeforeCloseEvent(View<?> source, CloseAction closeAction)
  • Method Details