Class Window.BeforeCloseEvent

java.lang.Object
java.util.EventObject
io.jmix.ui.component.Window.BeforeCloseEvent
All Implemented Interfaces:
Serializable
Enclosing interface:
Window

public static class Window.BeforeCloseEvent extends EventObject
Event sent right before the window is closed by an external (relative to the window content) action, like the button in the window tab or by the Esc keyboard shortcut.

The way the window is closing can be obtained via getCloseOrigin(). Closing can be prevented by invoking preventWindowClose(), for example: For example:

     @Subscribe(target = Target.FRAME)
     protected void onBeforeCloseFrame(Window.BeforeCloseEvent event) {
         if (event.getCloseOrigin() == CloseOriginType.BREADCRUMBS) {
             event.preventWindowClose();
         }
     }
 
See Also:
  • Field Details

    • closePrevented

      protected boolean closePrevented
    • closeOrigin

      protected Window.CloseOrigin closeOrigin
  • Constructor Details

    • BeforeCloseEvent

      public BeforeCloseEvent(Window source, Window.CloseOrigin closeOrigin)
      Parameters:
      source - the window to be closed
  • Method Details

    • getSource

      public Window getSource()
      Overrides:
      getSource in class EventObject
    • getCloseOrigin

      public Window.CloseOrigin getCloseOrigin()
      Returns:
      value that describes the event type: close by shortcut / using close button / from breadcrumbs
      See Also:
    • preventWindowClose

      public void preventWindowClose()
      Sets closePrevented flag to true and therefore prevents window close.
    • isClosePrevented

      public boolean isClosePrevented()
      Returns:
      true if at least one event handler called preventWindowClose() and window will not be closed