Hi, devs!
I’m mastering UI based on Composite
component.
But now I tried to grab some params from routing via BeforeEnterObserver
and to use them in Composite::initComponent()
and was confused - beforeEnter()
called after initContent
. :(
The reason is Vaadin uses getElement().getContent()
under the hood and therefore it calls initContent()
:
java.lang.RuntimeException: breakpoint
at com.citysense.elk.module.address_phone_book.profile.content.TestView.initContent(TestView.java:18)
at com.citysense.elk.module.address_phone_book.profile.content.TestView.initContent(TestView.java:11)
at com.vaadin.flow.component.Composite.getContent(Composite.java:129)
at com.vaadin.flow.component.Composite.getElement(Composite.java:173)
at com.vaadin.flow.router.EventUtil.collectBeforeEnterObserversFromChainElement(EventUtil.java:154)
at com.vaadin.flow.router.internal.AbstractNavigationStateRenderer.sendBeforeEnterEventAndPopulateChain(AbstractNavigationStateRenderer.java:512)
at com.vaadin.flow.router.internal.AbstractNavigationStateRenderer.createChainIfEmptyAndExecuteBeforeEnterNavigation(AbstractNavigationStateRenderer.java:482)
at com.vaadin.flow.router.internal.AbstractNavigationStateRenderer.handle(AbstractNavigationStateRenderer.java:226)
at com.vaadin.flow.component.internal.JavaScriptNavigationStateRenderer.handle(JavaScriptNavigationStateRenderer.java:78)
at com.vaadin.flow.component.UI.handleNavigation(UI.java:2005)
at com.vaadin.flow.component.UI.renderViewForRoute(UI.java:1968)
at com.vaadin.flow.component.UI.browserNavigate(UI.java:1833)
But is it right / expected behaviour? Looks like a bug for me.
I’m using Vaadin 24.4.8.