navigatin from UI/View to another UI

Hello.
What I want to do is a very simple task, navigate from an UI or View to another UI. I could achieve this with

getUI().getPage().setLocation("/myapp/anotherUi"); Is there a better way? I don’t want to hardcode “myapp” and possible not even “anotherUi”.

Thanks.

If you want to redirect to your current UI… but on your index View [
addView(“”, new View())
];

final String path = VaadinServlet.getCurrent()
                        .getServletContext().getContextPath()
                        + "/";
                UI.getCurrent().getPage().setLocation(path);

You can also use that again if you want to navigate to anotherUi by adding anotherUi.

final String path = VaadinServlet.getCurrent() .getServletContext().getContextPath() + "/anotherUi"; UI.getCurrent().getPage().setLocation(path); You can also make a static Variables for your servlets (UI) if you want to. :slight_smile:

Thank you very much. It will help.