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:
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
Modifier and TypeClassDescriptionstatic class
The second (afterView.BeforeCloseEvent
) event in the view closing process.static class
The first event in the view closing process.static class
The second (afterView.InitEvent
) event in the view opening process.static class
The first event in the view opening process.static class
An event informing which query parameters the view is opened with.static class
The last (afterView.BeforeShowEvent
) event in the view opening process. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected com.vaadin.flow.shared.Registration
addAfterCloseListener
(com.vaadin.flow.component.ComponentEventListener<View.AfterCloseEvent> listener) AddsView.AfterCloseEvent
listener.protected com.vaadin.flow.shared.Registration
addBeforeCloseListener
(com.vaadin.flow.component.ComponentEventListener<View.BeforeCloseEvent> listener) AddsView.BeforeCloseEvent
listener.protected com.vaadin.flow.shared.Registration
addBeforeShowListener
(com.vaadin.flow.component.ComponentEventListener<View.BeforeShowEvent> listener) AddsView.BeforeShowEvent
listener.protected com.vaadin.flow.shared.Registration
addInitListener
(com.vaadin.flow.component.ComponentEventListener<View.InitEvent> listener) AddsView.InitEvent
listener.protected com.vaadin.flow.shared.Registration
addQueryParametersChangeListener
(com.vaadin.flow.component.ComponentEventListener<View.QueryParametersChangeEvent> listener) AddsView.QueryParametersChangeEvent
listener.protected com.vaadin.flow.shared.Registration
addReadyListener
(com.vaadin.flow.component.ComponentEventListener<View.ReadyEvent> listener) AddsView.ReadyEvent
listener.void
afterNavigation
(com.vaadin.flow.router.AfterNavigationEvent event) void
beforeEnter
(com.vaadin.flow.router.BeforeEnterEvent event) void
beforeLeave
(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 theclose
action.protected org.springframework.context.ApplicationContext
getId()
protected com.vaadin.flow.router.QueryParameters
protected ViewActions
protected ViewAttributes
protected ViewData
protected ViewFacets
protected ViewSupport
boolean
protected void
onAttach
(com.vaadin.flow.component.AttachEvent attachEvent) protected void
onDetach
(com.vaadin.flow.component.DetachEvent detachEvent) protected void
setApplicationContext
(org.springframework.context.ApplicationContext applicationContext) void
void
setPreventBrowserTabClosing
(boolean preventBrowserTabClosing) Sets whether this view must prevent browser tab from accidentally closing.protected void
setViewActions
(ViewActions viewActions) protected void
setViewData
(ViewData viewData) protected void
setViewFacets
(ViewFacets viewFacets) Methods inherited from class com.vaadin.flow.component.Composite
getChildren, getContent, getElement, initContent
Methods 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, setVisible
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListener
Methods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListener
Methods 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) -
setId
- Overrides:
setId
in classcom.vaadin.flow.component.Component
-
getId
- Overrides:
getId
in classcom.vaadin.flow.component.Component
-
beforeEnter
public void beforeEnter(com.vaadin.flow.router.BeforeEnterEvent event) - Specified by:
beforeEnter
in interfacecom.vaadin.flow.router.internal.BeforeEnterHandler
-
beforeLeave
public void beforeLeave(com.vaadin.flow.router.BeforeLeaveEvent event) - Specified by:
beforeLeave
in interfacecom.vaadin.flow.router.internal.BeforeLeaveHandler
-
onAttach
protected void onAttach(com.vaadin.flow.component.AttachEvent attachEvent) - Overrides:
onAttach
in classcom.vaadin.flow.component.Component
-
onDetach
protected void onDetach(com.vaadin.flow.component.DetachEvent detachEvent) - Overrides:
onDetach
in classcom.vaadin.flow.component.Component
-
closeWithDefaultAction
Requests closing the view with theclose
action.- 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.AfterCloseEvent
and, 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:
getPageTitle
in interfacecom.vaadin.flow.router.HasDynamicTitle
-
addInitListener
protected com.vaadin.flow.shared.Registration addInitListener(com.vaadin.flow.component.ComponentEventListener<View.InitEvent> listener) AddsView.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, 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.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, 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.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, 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.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, 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.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, 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.QueryParametersChangeEvent
listener.- Parameters:
listener
- the listener to add, notnull
- Returns:
- a registration object that can be used for removing the listener
-