Passing arguments form one VerticalLayout to antoher

Hello,

I’m trying to make a pretty simple application. The idea is that I have one main VerticalLayout with grid of clients entity and after clicking on one row I want to see another VerticalLayout with pets that belong to that particular client.

My idea was to use parameter:

    grid.asSingleSelect().addValueChangeListener(event -> {
                clientId = grid.asSingleSelect().getValue().getId();
                grid.getUI().ifPresent(ui -> ui.navigate(PetView.class, clientId));
            }
    );

The problem is that setParameter method is called after constructor.

Do you know how can I pass Id argument from one VerticalLayout to another?

The problem is that setParameter method is called after constructor.

I do not se that as a problem. I suggest that you implement both HasUrlParameter and AfterNavigationObserver in PetView.

You can process the parameter in setParameter and store it as class field.

afterNavigation method is called each time you navigate to PetView. Thus that is the place where you should fetch data from the database according the given clientId. I assume you want to populate the view with fetched data.

Thanks Tatu!

I have just called method that updates grid in afterNavigation method and everything works like a charm!