I’d like to do nested routing to page with following format: axample.com/first_part/1234/second_part/444
Where 1234 and 4444 will be params for the routed view, is it possible with routing API?
@RoutePrefix("first_part")
public class MainView extends Div implements HasUrlParameter<Integer>, RouterLayout {
public MainView() {
//some code
}
@Override
public void setParameter(BeforeEvent event, Integer parameter) {
//some code
}
@Route(value = "second_part", layout = MainView.class)
public static class PathComponent extends VerticalLayout implements HasUrlParameter<Integer> {
public PathComponent() {
//some code
}
@Override
public void setParameter(BeforeEvent event, Integer parameter) {
//some code
}
}
}
I don’t realize what you trying to do. If you need a segment by page/component you must implement nested layout with @ParentLayout. If you only want the full path you can use the @WildcardParameter.
public class MainView extends Div implements RouterLayout {
public MainView() {
//some code
}
@Route(value = "first_part", layout = MainView.class)
public static class PathComponent extends VerticalLayout implements HasUrlParameter<String> {
public PathComponent() {
//some code
}
@Override
public void setParameter(BeforeEvent event, @WildcardParameter String parameter) {
System.out.println("Test: "+parameter);
}
}
}
Call the endpoint ‘/first_part/1/second_part/3’ to see the result.