Hi Vaadins,
it seems there are different solutions to navigate programmatically via UI.navigate. But what is the difference between the two different versions? One preferred over the other? Thanks for some explaining words.
grid.asSingleSelect().addValueChangeListener(event ->
UI.getCurrent().navigate(FlightDetailsView.class, new RouteParam("flight-id", event.getValue().getFlightId()))
);
grid.asSingleSelect().addValueChangeListener(event ->
grid.getUI().ifPresent(ui ->
ui.navigate(FlightDetailsView.class, new RouteParam("flight-id", event.getValue().getFlightId()))
)
);
this is usually true for component listener, unless you are doing updates in a background thread without using UI.access() (in this case you should always store a UI reference and execute the update action in an UI.access call)
They all end up calling the same method. Choose what is better for your code.
Just for clarity, I was talking about the navigate method here, not about getting the UI instance