'How to create Vaadin flow MprRouteAdapter for registered Vaadin 8 view with parameterized constructor?

I have the following code snippet in Vaadin 8 to navigate to ShipmentView. The shipment view is registered with two parameter constructor:

navigator.addView("shipment", new ShipmentView("name", "shipmentId"));
navigator.navigateTo("shipment");

During the migration process, we decide to migrate ShipmentView later and use MprRouteAdapter first.

if the view does not require the two parameter constructor, we can have the following adapter and navigate with code UI.getCurrent().navigate(ShipmentViewRoute .class)).

@Route(value = "shipment", layout = MainLayout.class)
public class ShipmentViewRoute extends MprRouteAdapter<ShipmentView>  {

    public ShipmentViewRoute () {
        this.setSizeFull();
    }
}

With the two parameter "name"and "shipmentId", how can I create the Adapter?

Thanks you in advance.



Solution 1:[1]

I think the most straightforward way is just to hard-code those parameters in the constructor (or fetch them from wherever you would get them from when initializing the navigator in the old code).

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ollitietavainen