Class View<T extends com.vaadin.flow.component.Component>

java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.Composite<T>
io.jmix.flowui.view.View<T>
Type Parameters:
T - type of the root UI component
All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier, com.vaadin.flow.component.DetachNotifier, com.vaadin.flow.component.HasElement, com.vaadin.flow.component.HasStyle, com.vaadin.flow.router.AfterNavigationObserver, com.vaadin.flow.router.BeforeEnterObserver, com.vaadin.flow.router.BeforeLeaveObserver, com.vaadin.flow.router.HasDynamicTitle, com.vaadin.flow.router.internal.AfterNavigationHandler, com.vaadin.flow.router.internal.BeforeEnterHandler, com.vaadin.flow.router.internal.BeforeLeaveHandler, Serializable
Direct Known Subclasses:
HeaderPropertyFilterLayout, StandardMainView, StandardView

public class View<T extends com.vaadin.flow.component.Component> extends com.vaadin.flow.component.Composite<T> implements com.vaadin.flow.router.BeforeEnterObserver, com.vaadin.flow.router.AfterNavigationObserver, com.vaadin.flow.router.BeforeLeaveObserver, com.vaadin.flow.router.HasDynamicTitle
Base class for UI views.

A view is a building block of application UI. It contains UI components, data components and facets, that are usually defined in linked XML descriptors.

A view can be shown either as a web page with its own URL (using ViewNavigators), or inside a dialog window (using DialogWindows).

Views are registered in the application using the ViewController annotation on the view class.

A view sends lifecycle events: View.InitEvent, View.BeforeShowEvent, View.ReadyEvent, View.BeforeCloseEvent, View.AfterCloseEvent.

See Also:
  • Constructor Details

    • View

      public View()
  • Method Details

    • getReturnParameters

      protected com.vaadin.flow.router.QueryParameters getReturnParameters()
    • getApplicationContext

      protected org.springframework.context.ApplicationContext getApplicationContext()
    • setApplicationContext

      @Autowired protected void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
    • setMeterRegistry

      @Autowired protected void setMeterRegistry(io.micrometer.core.instrument.MeterRegistry meterRegistry)
    • setId

      public void setId(String id)
      Overrides:
      setId in class com.vaadin.flow.component.Component
    • getId

      public Optional<String> getId()
      Overrides:
      getId in class com.vaadin.flow.component.Component
    • afterNavigation

      public void afterNavigation(com.vaadin.flow.router.AfterNavigationEvent event)
      Specified by:
      afterNavigation in interface com.vaadin.flow.router.internal.AfterNavigationHandler
    • beforeEnter

      public void beforeEnter(com.vaadin.flow.router.BeforeEnterEvent event)
      Specified by:
      beforeEnter in interface com.vaadin.flow.router.internal.BeforeEnterHandler
    • beforeLeave

      public void beforeLeave(com.vaadin.flow.router.BeforeLeaveEvent event)
      Specified by:
      beforeLeave in interface com.vaadin.flow.router.internal.BeforeLeaveHandler
    • onAttach

      protected void onAttach(com.vaadin.flow.component.AttachEvent attachEvent)
      Overrides:
      onAttach in class com.vaadin.flow.component.Component
    • onDetach

      protected void onDetach(com.vaadin.flow.component.DetachEvent detachEvent)
      Overrides:
      onDetach in class com.vaadin.flow.component.Component
    • closeWithDefaultAction

      public OperationResult closeWithDefaultAction()
      Requests closing the view with the close action.
      Returns:
      result of close request
      See Also:
    • close

      public OperationResult close(StandardOutcome outcome)
      Requests closing the view with the given outcome.
      Parameters:
      outcome - StandardOutcome
      Returns:
      result of close request
    • close

      public OperationResult close(CloseAction closeAction)
      Requests closing of the view caused by the given action.
      Parameters:
      closeAction - close action which is propagated to View.BeforeCloseEvent, View.AfterCloseEvent and, if the view has been opened in a dialog, to DialogWindow.AfterCloseEvent.
      Returns:
      result of close request
    • isPreventBrowserTabClosing

      public boolean isPreventBrowserTabClosing()
      Returns:
      whether this view prevents browser tab from accidentally closing
    • setPreventBrowserTabClosing

      public void setPreventBrowserTabClosing(boolean preventBrowserTabClosing)
      Sets whether this view must prevent browser tab from accidentally closing. Enabled by default.
      Parameters:
      preventBrowserTabClosing - whether this details view must prevent browser tab from accidentally closing
    • getViewData

      protected ViewData getViewData()
    • setViewData

      protected void setViewData(ViewData viewData)
    • getViewActions

      protected ViewActions getViewActions()
    • setViewActions

      protected void setViewActions(ViewActions viewActions)
    • getViewFacets

      protected ViewFacets getViewFacets()
    • setViewFacets

      protected void setViewFacets(ViewFacets viewFacets)
    • getViewAttributes

      protected ViewAttributes getViewAttributes()
    • getViewSupport

      protected ViewSupport getViewSupport()
    • getPageTitle

      public String getPageTitle()
      Specified by:
      getPageTitle in interface com.vaadin.flow.router.HasDynamicTitle
    • addInitListener

      protected com.vaadin.flow.shared.Registration addInitListener(com.vaadin.flow.component.ComponentEventListener<View.InitEvent> listener)
      Adds View.InitEvent listener.

      You can also add an event listener declaratively using a controller method annotated with Subscribe:

          @Subscribe
          protected void onInit(InitEvent event) {
             // handle event here
          }
       
      Parameters:
      listener - the listener to add, not null
      Returns:
      a registration object that can be used for removing the listener
    • addBeforeShowListener

      protected com.vaadin.flow.shared.Registration addBeforeShowListener(com.vaadin.flow.component.ComponentEventListener<View.BeforeShowEvent> listener)
      Adds View.BeforeShowEvent listener.

      You can also add an event listener declaratively using a controller method annotated with Subscribe:

          @Subscribe
          protected void onBeforeShow(BeforeShowEvent event) {
             // handle event here
          }
       
      Parameters:
      listener - the listener to add, not null
      Returns:
      a registration object that can be used for removing the listener
    • addReadyListener

      protected com.vaadin.flow.shared.Registration addReadyListener(com.vaadin.flow.component.ComponentEventListener<View.ReadyEvent> listener)
      Adds View.ReadyEvent listener.

      You can also add an event listener declaratively using a controller method annotated with Subscribe:

          @Subscribe
          protected void onReady(ReadyEvent event) {
             // handle event here
          }
       
      Parameters:
      listener - the listener to add, not null
      Returns:
      a registration object that can be used for removing the listener
    • addBeforeCloseListener

      protected com.vaadin.flow.shared.Registration addBeforeCloseListener(com.vaadin.flow.component.ComponentEventListener<View.BeforeCloseEvent> listener)
      Adds View.BeforeCloseEvent listener.

      You can also add an event listener declaratively using a controller method annotated with Subscribe:

          @Subscribe
          protected void onBeforeClose(BeforeCloseEvent event) {
             // handle event here
          }
       
      Parameters:
      listener - the listener to add, not null
      Returns:
      a registration object that can be used for removing the listener
    • addAfterCloseListener

      protected com.vaadin.flow.shared.Registration addAfterCloseListener(com.vaadin.flow.component.ComponentEventListener<View.AfterCloseEvent> listener)
      Adds View.AfterCloseEvent listener.

      You can also add an event listener declaratively using a controller method annotated with Subscribe:

          @Subscribe
          protected void onAfterClose(AfterCloseEvent event) {
             // handle event here
          }
       
      Parameters:
      listener - the listener to add, not null
      Returns:
      a registration object that can be used for removing the listener
    • addQueryParametersChangeListener

      protected com.vaadin.flow.shared.Registration addQueryParametersChangeListener(com.vaadin.flow.component.ComponentEventListener<View.QueryParametersChangeEvent> listener)
      Parameters:
      listener - the listener to add, not null
      Returns:
      a registration object that can be used for removing the listener