Flow View.enter(ViewChangeEvent) replacement?

In Vaadin 8, I used to set up the MVP in void enter(ViewChangeListener.ViewChangeEvent event), what would be the Route-equivalent in Flow? With Vaadin CDI @RouteScoped one would think a @PostConstruct might be pretty close but are there more natural alternatives?

BTW, haven’t tried but could the View and the Presenter cross-@Inject each other with @NormalRouteScoped or will there be a circular dependency even if both are proxied? Or can it be done if the other is a @RouteScoped?

There are actually two events you can choose from. The other is beforeEnter and the other is afterNavigation. You can use these by implementing BeforeEnterObserver and AfterNavigationObserver interfaces.

The both and other things about Router are explained in Router training video which you can find here: https://vaadin.com/training/courses?type=all

With Vaadin CDI @RouteScoped one would think a @PostConstruct might be pretty close but are there more natural alternatives?

Yes, that is possible alternative in some cases as well.

could the View and the Presenter cross-@Inject each other

At least with Vaadin 7 & 8 that was not possible (or more specifically typical Bean manager implementations do not allow this). The pattern we have used is to inject view (or here the route) to presenter and let the view to set presenter with methods.

Ah, just what I was looking for

This is probably not a bug, more of me not understanding how routing works but if I have a Login component and a Admin component and an UI-level BeforeEnterListener that checks for an annotation-based access rights and in case of failure, reroutes back to the login page, I end up with two login components on the page. So the routing goes like

  1. Click login button → route to Admin view
  2. BeforeEnterListener says no-go, reroutes back to Login
  3. Login-page now has to two login components