Navigation
To call a view, it needs a path, which is also called a route.
-
First you have to select the root element of the view
-
Then specify any path under Routing > Route. (Can also be an empty string)
Each route must be unique. There can never be multiple views with the same route at the same time |
Navigate to another view
Complex Navigation
Sometimes various information must also be passed to the view to be called. The following code snippets can be used for this purpose:
// Es können Datentypen wie z.B. String übergeben werden
UI.getCurrent().navigate(OtherView.class, "Hallo Welt");
In OtherView.class the HasUrlParameter<String> interface must be implemented. To get the parameter there now, the following method must be implemented:
@Override
public void setParameter(final BeforeEvent event, final String parameter)
{
System.out.println("Parameter was " + parameter);
}
Among others, Query parameters can also be passed. More about this can be read here: https://vaadin.com/docs/v14/flow/routing/tutorial-router-url-parameters
However, whole objects can also be passed using the RapidClipse framework.
Navigation.To(OtherView.class)
.withParameter("myData", myData)
.navigate();
To do this, the following must be implemented in OtherView.java:
@NavigationParameter
private MyDataType myData;
@Override
public void navigationParametersUpdated()
{
System.out.println("myData is now available!");
}
|