Class MainLayout
- 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.internal.AfterNavigationHandler, com.vaadin.flow.router.RouterLayout, Serializable
- Direct Known Subclasses:
MobileMainLayout
Suites as such for small apps that has no special needs for the main layout.
Menu items can be configured (override caption, order, icon) using
MenuItem annotation
Check usage example from the text package org.vaadin.firitin.appframework
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.vaadin.flow.component.applayout.AppLayout
com.vaadin.flow.component.applayout.AppLayout.AppLayoutI18n, com.vaadin.flow.component.applayout.AppLayout.Section -
Field Summary
Fields inherited from class VAppLayout
navbarHelpers -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidafterNavigation(com.vaadin.flow.router.AfterNavigationEvent event) voidThis method can be called to re-build the menu, if e.g. views has been added, removed or otherwise changed.protected booleancheckAccess(NavigationItem navigationItem) Application that has e.g. role based access control can limit the appearance of the navigation item in the menu by returning false here.protected List<NavigationItem> getChildItems(NavigationItem parent) The child navigation items of the given (parent/group) item, in menu order.static MainLayoutAssuming an attached component is within o view utilizing MainLayout, this method returns the current MainLayout.protected voidinit()protected voidonAttach(com.vaadin.flow.component.AttachEvent attachEvent) protected voidonMenuBuilt(List<NavigationItem> topLevelItems) Called at the end ofbuildMenu()with the visible, access-filtered and ordered top-level navigation items (the same ones just rendered into the drawerSideNav).protected voidsortMenuItems(List<NavigationItem> navigationItems) Methods inherited from class VAppLayout
addDrawerContent, addHeaderContent, addNavbarHelper, closeSubView, closeSubView, getDrawerFooter, getDrawerHeader, getMenu, getMenuScroller, getMenuText, getNavbarHelpers, getViewTitle, openSubView, openSubView, prepareDrawerFooter, prepareNav, setContent, setViewTitle, showContent, updateViewTitleMethods inherited from class com.vaadin.flow.component.applayout.AppLayout
addToDrawer, addToNavbar, addToNavbar, bindDrawerOpened, getContent, getI18n, getPrimarySection, isDrawerOpened, isOverlay, remove, setDrawerOpened, setI18n, setPrimarySection, showRouterLayoutContentMethods inherited from class com.vaadin.flow.component.Component
addListener, bindVisible, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTestId, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setTestId, setVisibleMethods inherited from class 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.HasElement
getElementMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, bindClassName, bindClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassNameMethods inherited from interface com.vaadin.flow.router.RouterLayout
removeRouterLayoutContent
-
Constructor Details
-
MainLayout
public MainLayout()
-
-
Method Details
-
onAttach
protected void onAttach(com.vaadin.flow.component.AttachEvent attachEvent) - Overrides:
onAttachin classcom.vaadin.flow.component.Component
-
init
protected void init() -
sortMenuItems
-
buildMenu
public void buildMenu()This method can be called to re-build the menu, if e.g. views has been added, removed or otherwise changed.If you have dynamically added/removed views from another thread, wrap the behavior in UI.access method.
-
onMenuBuilt
Called at the end ofbuildMenu()with the visible, access-filtered and ordered top-level navigation items (the same ones just rendered into the drawerSideNav). The default implementation does nothing.Subclasses can use this to build an additional navigation presentation from the same model, e.g. a mobile bottom navigation bar (see
MobileMainLayout). The items carry their navigation target, icon (MenuItem/Menu) and translated label, so the alternative presentation stays in sync with access control, ordering and i18n for free. It is called again whenever the menu is rebuilt (routes added or removed), so rebuild the alternative presentation from scratch here.- Parameters:
topLevelItems- the visible top-level items, in menu order
-
getCurrent
Assuming an attached component is within o view utilizing MainLayout, this method returns the current MainLayout. In a bigger projects it is most often better to inject the parent layout if needed and use a more specific type.- Returns:
- the current main layout.
-