How can I read the route parameter in Jmix 2?

I searched the documentation, but unfortunately, I did not find anything.
Let’s assume I have the following view definition:

@Route(value = "report-view/:customer/:anotherparam", layout = MainView.class)
@ViewController(id = "ReportView")
@ViewDescriptor(path = "report-view.xml")
public class ReportView extends StandardView {
....

The view has the route parameters ‘customer’ and ‘anotherparam’. How can I read these route params and use them in the ‘onInit’ event? What is the best way of doing this?

Hi,

These parameters cannot be accesses in the InitEvent. They are available in the BeforeEnterEvent and AfterNavigationEvent Vaadin navigation lifecycle events handlers e.g.:

@Override
public void beforeEnter(BeforeEnterEvent event) {
    super.beforeEnter(event);

    RouteParameters routeParameters = event.getRouteParameters();
    // ...
}

@Override
public void afterNavigation(AfterNavigationEvent event) {
    super.afterNavigation(event);

    RouteParameters routeParameters = event.getRouteParameters();
    // ...
}

NOTE: you must call super method to have a view work properly.

Regards,
Gleb