NavigationState, UI.navigate(), and BeforeEnter

Using the Vaadin Flow framework I find that I have two models that I need to use to describe a routing destination. If I’m initiating UI navigation server-side then I end up calling the UI.navigate() and describing the destination with a class and perhaps a parameter - type-safe and easy.
If I’m intercepting with a BeforeEnterObserver I’m able to navigate based on destination class, but not if I have a parameter - in which case I need to either construct a NavigationState object or I have to translate my destination class into a String route.

Am I missing some utility class that makes these consistent? How are others dealing with these two scenarios? Is there a known reason that BeforeEnterEvent.forwardTo() doesn’t have a method that has the same parameters as UI.navigate(Class target, T parameter)?

Thanks

Hi.

I have a feeling that this was something that didn’t come to mind when extending the rerouteTo/forwardTo functionality.

Could you open an new issue to [Flow]
(https://github.com/vaadin/flow/issues) about adding the missing methods that
take in Class<? extends Component>, T and Class<? extends Component>, List<T> to the BeforeEvent

  • Mikael

Done. For reference: https://github.com/vaadin/flow/issues/8873