Class View<T extends com.vaadin.flow.component.Component>
- 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
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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThe second (afterView.BeforeCloseEvent) event in the view closing process.static classThe first event in the view closing process.static classThe second (afterView.InitEvent) event in the view opening process.static classThe first event in the view opening process.static classAn event informing which query parameters the view is opened with.static classThe last (afterView.BeforeShowEvent) event in the view opening process. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected com.vaadin.flow.shared.RegistrationaddAfterCloseListener(com.vaadin.flow.component.ComponentEventListener<View.AfterCloseEvent> listener) AddsView.AfterCloseEventlistener.protected com.vaadin.flow.shared.RegistrationaddBeforeCloseListener(com.vaadin.flow.component.ComponentEventListener<View.BeforeCloseEvent> listener) AddsView.BeforeCloseEventlistener.protected com.vaadin.flow.shared.RegistrationaddBeforeShowListener(com.vaadin.flow.component.ComponentEventListener<View.BeforeShowEvent> listener) AddsView.BeforeShowEventlistener.protected com.vaadin.flow.shared.RegistrationaddInitListener(com.vaadin.flow.component.ComponentEventListener<View.InitEvent> listener) AddsView.InitEventlistener.protected com.vaadin.flow.shared.RegistrationaddQueryParametersChangeListener(com.vaadin.flow.component.ComponentEventListener<View.QueryParametersChangeEvent> listener) AddsView.QueryParametersChangeEventlistener.protected com.vaadin.flow.shared.RegistrationaddReadyListener(com.vaadin.flow.component.ComponentEventListener<View.ReadyEvent> listener) AddsView.ReadyEventlistener.voidafterNavigation(com.vaadin.flow.router.AfterNavigationEvent event) voidbeforeEnter(com.vaadin.flow.router.BeforeEnterEvent event) voidbeforeLeave(com.vaadin.flow.router.BeforeLeaveEvent event) close(CloseAction closeAction) Requests closing of the view caused by the given action.close(StandardOutcome outcome) Requests closing the view with the given outcome.Requests closing the view with thecloseaction.protected org.springframework.context.ApplicationContextgetId()protected com.vaadin.flow.router.QueryParametersprotected ViewActionsprotected ViewAttributesprotected ViewDataprotected ViewFacetsprotected ViewSupportbooleanprotected voidonAttach(com.vaadin.flow.component.AttachEvent attachEvent) protected voidonDetach(com.vaadin.flow.component.DetachEvent detachEvent) protected voidsetApplicationContext(org.springframework.context.ApplicationContext applicationContext) voidprotected voidsetMeterRegistry(io.micrometer.core.instrument.MeterRegistry meterRegistry) voidsetPreventBrowserTabClosing(boolean preventBrowserTabClosing) Sets whether this view must prevent browser tab from accidentally closing.protected voidsetViewActions(ViewActions viewActions) protected voidsetViewData(ViewData viewData) protected voidsetViewFacets(ViewFacets viewFacets) Methods inherited from class com.vaadin.flow.component.Composite
getChildren, getContent, getElement, initContentMethods inherited from class com.vaadin.flow.component.Component
addListener, findAncestor, fireEvent, from, get, getEventBus, getListeners, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setVisibleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListenerMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
-
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
- Overrides:
setIdin classcom.vaadin.flow.component.Component
-
getId
- Overrides:
getIdin classcom.vaadin.flow.component.Component
-
beforeEnter
public void beforeEnter(com.vaadin.flow.router.BeforeEnterEvent event) - Specified by:
beforeEnterin interfacecom.vaadin.flow.router.internal.BeforeEnterHandler
-
beforeLeave
public void beforeLeave(com.vaadin.flow.router.BeforeLeaveEvent event) - Specified by:
beforeLeavein interfacecom.vaadin.flow.router.internal.BeforeLeaveHandler
-
onAttach
protected void onAttach(com.vaadin.flow.component.AttachEvent attachEvent) - Overrides:
onAttachin classcom.vaadin.flow.component.Component
-
onDetach
protected void onDetach(com.vaadin.flow.component.DetachEvent detachEvent) - Overrides:
onDetachin classcom.vaadin.flow.component.Component
-
closeWithDefaultAction
Requests closing the view with thecloseaction.- Returns:
- result of close request
- See Also:
-
close
Requests closing the view with the given outcome.- Parameters:
outcome-StandardOutcome- Returns:
- result of close request
-
close
Requests closing of the view caused by the given action.- Parameters:
closeAction- close action which is propagated toView.BeforeCloseEvent,View.AfterCloseEventand, if the view has been opened in a dialog, toDialogWindow.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
-
setViewData
-
getViewActions
-
setViewActions
-
getViewFacets
-
setViewFacets
-
getViewAttributes
-
getViewSupport
-
getPageTitle
- Specified by:
getPageTitlein interfacecom.vaadin.flow.router.HasDynamicTitle
-
addInitListener
protected com.vaadin.flow.shared.Registration addInitListener(com.vaadin.flow.component.ComponentEventListener<View.InitEvent> listener) AddsView.InitEventlistener.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, notnull- 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) AddsView.BeforeShowEventlistener.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, notnull- 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) AddsView.ReadyEventlistener.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, notnull- 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) AddsView.BeforeCloseEventlistener.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, notnull- 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) AddsView.AfterCloseEventlistener.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, notnull- 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) AddsView.QueryParametersChangeEventlistener.- Parameters:
listener- the listener to add, notnull- Returns:
- a registration object that can be used for removing the listener
-