Handling URL Changes

The framework automatically reacts to the changes in the application URL: it tries to resolve the requested route and performs history navigation or opens a screen registered for this route.

When a screen is opened by a route with parameters, the framework sends UrlParamsChangedEvent to the screen controller before the screen is shown. The same happens when the URL parameters are changed while the screen is opened. You can subscribe to this event to handle the initial parameters and their changes. For example, you can load data or hide/show screen UI components depending on the URL parameters.

An example of subscribing to the event in a screen controller:

@Subscribe
protected void onUrlParamsChanged(UrlParamsChangedEvent event) {
    //...
}

See a complete example of using UrlParamsChangedEvent below.