Documentation versions (currently viewingVaadin 14)

You are viewing documentation for an older Vaadin version. View latest documentation

Step 3 - Running a Vaadin Legacy CDI application with MPR and Flow

This step is needed in case your Vaadin 7 or 8 application uses CDI. If it is not the case, go back to the framework selection.

Updating to the correct CDI version

Remove any version from com.vaadin:vaadin-cdi as the proper Vaadin 14 compatible version for it is managed by the vaadin-bom:


Handling of CDIUI annotation

Instead of @CDIUI use @Route.

public class TodoUI extends UI {
    protected void init(VaadinRequest vaadinRequest) {
        setContent(new HorizontalLayout());

can for instance be replaced with

public class TodoUI extends Div implements HasLegacyComponents {
    private void buildLayouts() {
        add(new HorizontalLayout());
Annotations in the UI, such as @Theme and @Title and so on, will be dealt with later on in the tutorial. Most of them have similar counterpart in either Flow or MPR.

What to do with CDIView

Any @CDIView should be updated to a Flow Route by wrapping them as a MprRouteAdapter<? extends View> or re-writing it to be a Flow Component. See Migrating Views to Flow Routes

What to do with ViewScopes

All ViewScopes should be changed to RouteScopes e.g.

  • @ViewScoped to @RouteScoped

  • @NormalViewScoped to @NormalRouteScoped

In some projects CDI has ignored the archive and not instantiated objects as expected. This is fixed by adding a beans.xml (empty is fine) file to src/main/webapp/WEB_INF.