Hi,
I need to deploy my web app as a servlet to my http server. With Framework 8, this works fine (because I can specify the ui with @VaadinServletConfiguration).
Is there a way to this with Flow adn automtic routing as well?
Best regards,
K.
Hi,
So I could deploy the @Route component via servlet:
public class MyUI extends UI {
@VaadinServletConfiguration(ui = MyUI.class, productionMode = false)
@WebServlet(urlPatterns = "/*", name = "static-menu", asyncSupported = true,
initParams = {
@WebInitParam(name = "frontend.url.es6", value = "http://mydomain.com/es6/"),
@WebInitParam(name = "frontend.url.es5", value = "http://mydomain.com/es5/")
})
public static class MyUIServlet extends VaadinServlet {
private static final long serialVersionUID = 1L;
public MyUIServlet() throws Throwable {
}
@Override
protected void servletInitialized() throws ServletException {
super.servletInitialized();
try {
((RouteRegistry) getServletContext().getAttribute(RouteRegistry.class.getName())).
setNavigationTargets(new HashSet<Class<? extends Component>>() {{
add(MainView.class);
}});
} catch (Throwable ex) {
throw new ServletException(ex);
}
}
}
@Override
protected void init(VaadinRequest request) {
}
}
where the MainView class as in the Vaadin examples:
@Route
public class MainView extends VerticalLayout implements RouterLayout{
public MainView() {
com.vaadin.flow.component.textfield.TextField textField = new TextField();
...
add(textField);
}
}
Route is stored in the ServletContext. I register my Route component direct via the servlet, when it is initialized.
Best regards, K.
I have exactly the same question and this is the only solution i can find. Is this the only way to do this? as reading the vaadin docs it suggests you shouldnt need to do this as a Ui class is not required when ising @Route