1

I'm trying to migrate a Vaadin 8 application to Vaadin 11.

I'm trying to use VaadinServlet and UI:

@WebServlet(value = "/*", asyncSupported = true)
@VaadinServletConfiguration(productionMode = false, ui = TestUi.class)
public class TestServlet extends VaadinServlet {
}

public class TestUi extends UI {
  @Override
  protected void init(VaadinRequest request) {
    add(new Label("Test"));
  }
}

I get:

enter image description here

Can / do I have to disable Router?

I double checked, there is no class annotated with @Route.

Update: The migration guide states: enter image description here

So I am still confused about why and where I am supposed to put the Route annotation in this scenario.

Reto Höhener
  • 5,419
  • 4
  • 39
  • 79
  • What's the reason that you want to disable router? I don't think it's possible. If you do not want to have navigation by URLs you will need at least the `@Route("")` default URL. – Steffen Harbich Nov 21 '18 at 07:20
  • I want to upgrade from 8 with the least amount of changes possible. The old app didn't use Navigator, so I thought Routes might be optional, too. I will try to make it work with `@Route("")`. – Reto Höhener Nov 21 '18 at 07:38
  • 2
    "I want to upgrade from 8 with the least amount of changes possible. " <-- I need to give you slight warning about this. There are some major changes between 8 and 10. So "upgrade" is in most cases a wrong term. So be prepared to refactor things. It depends on your application. If you have very simple application, which does not have any add-ons, any custom client side, only basic components used, no custom theming etc. it might be possible to upgrade with minimal changes. Otherwise it is not possible. – Tatu Lund Nov 21 '18 at 09:33
  • Thank you Tatu. I should have said migrate, I guess. I did say 'least amount possible' however, not 'minimal changes' ;). I did read the migration guide and have already spent several days migrating many parts of the application. Should have started with the navigation part. – Reto Höhener Nov 21 '18 at 10:38

1 Answers1

3

You will need to have at least one @Route in Vaadin 10. Since you're migrating, you might want to check the documentation here: https://vaadin.com/docs/v10/flow/migration/1-migrating-v8-v10.html

ollitietavainen
  • 3,900
  • 13
  • 30
  • Thank you for confirming. Seeing that you are a Vaadin developer, I will just take your word for it. I am confused now about whether it makes ever sense to use VaadinServlet / UI at all. – Reto Höhener Nov 21 '18 at 10:42
  • The migration guide states: "You can of course still configure the servlet yourself, and it happens the same way as previously". https://vaadin.com/docs/v11/flow/migration/3-general-differences.html – Reto Höhener Nov 21 '18 at 11:07
  • 1
    This is one of the big changes in Vaadin 10. The UI and its init method isn't really the entry point of the application. Instead, you define a root component with a Route and build from there. The VaadinServlet is still there and you get one automatically, but you don't need to touch it if you don't need e.g. custom bootstrapping or something. – ollitietavainen Nov 23 '18 at 08:07
  • 2
    Yes thank you very much, it's starting to work out nicely now, once I figured out about route (wildcard) parameters. I'll post my results when I am reasonably satisfied and convinced that it works. I must say I love Vaadin 11 soo much better than 8 so far. It feels like I've been waiting for 15 years for a java web framework to give me this clear, straightforward access to the DOM, CSS and JavaScript. – Reto Höhener Nov 23 '18 at 08:15