Is there a way to do nested routing with url params?

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
        }
    }

}

This way is not working

Take a look at vaadin documentation about [Wildcard URL parameters for Navigation Targets]
(https://vaadin.com/docs/v10/flow/routing/tutorial-router-url-parameters.html).
You could mix the annotation WildcardParameter with [nestead layouts]
(https://vaadin.com/docs/v10/flow/routing/tutorial-router-layout.html) also.

I changed code and added an annotation @WildcardParameter to parameter and there is not difference. I have the same exception as before

@RoutePrefix("first_part")
public class MainView extends Div implements HasUrlParameter<Integer>, RouterLayout {

    public MainView() {
        //some code
    }

    @Override
    public void setParameter(BeforeEvent event, @WildcardParameter 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
        }
    }

}

17092791.png

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.

Thanks, just using @WildcardParameter without any nested layouts is suitable for me