Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Redirect Vaadin App
I am currently hosting my vaadin app on openshift. My main website redirects to the vaadin app when the login button is clicked. The first thing the user sees is the login page
I have 2 buttons on my website, a free trial button and a login button, and I have 2 different classes in my vaadin app, a login class and a free trial class.
How can I make the login button redirect to the login class of my vaadin app and the free trial button redirect to the free trial class of my vaadin app?
This is what it currently looks like:
@Theme("mytheme")
@Widgetset("com.example.myapp.MyAppWidgetset")
@PreserveOnRefresh
public class MyUI extends UI {
@WebServlet(urlPatterns = "/*", name = "MyUIServlet", asyncSupported = true)
@VaadinServletConfiguration(ui = MyUI.class, productionMode = false)
public static class MyUIServlet extends VaadinServlet {
}
@Override
protected void init(VaadinRequest vaadinRequest) {
login();
}
Hi,
sounds like you want a Navigator. Take a look at the Book of Vaadin chapter Navigating in an Application.
Hope this helps,
Olli
Olli Tietäväinen: Hi,
sounds like you want a Navigator. Take a look at the Book of Vaadin chapter Navigating in an Application.
Hope this helps,
Olli
Thank you! Would you have any insight into how to implement this for my situation? I read through the docs but I dont really understand it.
How can I use this to redirect www.trial.mywebsite.com to the trialUI class
And redirect www.login.mywebsite.com to the LoginUI class?
Hi,
Navigator works with URI Fragments, so it won't help you go to a different subdomain like that. Vaadin applications are single-page applications - different "pages" like mysite.com/#login or mysite.com/#signup are just views you display in the same browser page. You can of course serve multiple Vaadin Servlets from the same domain and redirect between them, for example by using Page.getCurrent().setLocation(). However, that would not (in my opinion) be a good architecture in a case where you just use to provide different views for the same app. That doesn't mean you have to give up anything like access control, bookmarkable links or browser back button behavior - they work just as well with single-page applications.
If you just want to see a simple working example, take a look at the Book of Vaadin examples about Navigator.
-Olli