How to pass a parameter to antoher view?

I am using Vaadin 14 and I have got a view with a list of elements. The user should select one. I want to open another view (onClickListener) that shows the details, so i want to pass the selected id to another view. How to dot it?
I have tried with this:

on the source view:
Map<String, List<String>> parametersMap = new HashMap<String, List<String>>();
	parametersMap.put(selectedId, Arrays.asList(String.valueOf(item.getID)));
and on the reviewing view
QueryParameters queryParameters = new QueryParameters(parametersMap);
this.getUI().ifPresent(ui -> ui.navigate("view", queryParameters));

But then i always get an error, and even with optionalParameters annotation.
I wonder why this is so difficult to find out. Any suggestions are welcome.

Hi,

If you want to navigate with a single parameter (integer or String for example). I recommend to use the class name instead of the string.
For example with an optional integer (id) :

@Route("parameters")
public class ParametersView extends VerticalLayout implements HasUrlParameter<Integer> {

    public ParametersView() {
        Button button1 = new Button("Navigate to Id 1", event -> {
            getUI().ifPresent(ui -> ui.navigate(ParametersView.class, 1));
        });

        Button buttonNULL = new Button("Navigate with no id", event -> {
            getUI().ifPresent(ui -> ui.navigate(ParametersView.class));
        });


        Button button2 = new Button("Navigate with Id 2", event -> {
            // not recommended
            getUI().ifPresent(ui -> ui.navigate("parameters/2"));
        });
        add(button1, button2, buttonNULL);
    }

    @Override
    public void setParameter(BeforeEvent event, @OptionalParameter Integer id) {
        // get your id
        if (id != null) {
            Notification.show("Parameter updated " + id);
        } else {
            Notification.show("Parameter updated NULL");
        }
    }
}