Blog

Vaadin CDI for Vaadin 10 now available for testing

By  
Matti Tahvonen
Matti Tahvonen
·
On Sep 3, 2018 7:26:00 AM
·

Vaadin CDI 10.0.0.beta1 is now available. Vaadin CDI integration library has been an important tool for many Vaadin developers, but we wanted to scope it out of initial Vaadin 10 release to get the first version of the new platform out sooner.

The new version builds on the same old principles as the old version. Active Vaadin contributor Tamás Kimmel built the first CDI integration for Vaadin 10 even before final stable version of Vaadin 10 was out. Now he has been working actively with the Flow team to bake it into a stable Vaadin supported official CDI integration.

Code examples and initial features

Integration to a CDI is now easier than ever. The fundamental changes we did in Vaadin Flow, allows better integration tools like CDI. You’ll only need the very same @Route annotation that you’ll use with plain servlet setups as well. MainView automatically becomes a managed bean and you can, for example, inject other CDI beans into your UI classes.

@Route
public class MainView extends VerticalLayout {

    @Inject
    public MainView(Greeter greeter) {
        add(new Span(greeter.sayHello()));
    }

}
 

You have the same scopes you had before, except that view scope is now replaced with Route scope and we expect it to be the most commonly used scope for Vaadin UI beans.

  • VaadinServiceScoped
  • VaadinSessionScoped
  • UIScoped
  • RouteScoped
  • NormalUIScoped
  • NormalRouteScoped

Refer to the readme file of the project to see more a complete list of features.

The tutorial and documentation are still under construction, but you can already use the tutorial app and integration tests as examples.

Try it out today

Vaadin Flow compatible version will be officially released among an upcoming platform release, but you can already use it with Vaadin 10 and we want your help to test it. The Vaadin CDI 10.0.0.beta1 is available via our pre-release repository already, and it is compatible with the Vaadin 10. With following pom.xml snippets, you can start using your CDI skills with your current Vaadin 10 project.

Vaadin pre-release repository:

    <repositories>
        <repository>
            <id>vaadin-prereleases</id>
            <url>https://maven.vaadin.com/vaadin-prereleases</url>
        </repository>
    </repositories>
 

Vaadin Flow compatible Vaadin CDI dependency:

  <dependency>
      <groupId>com.vaadin</groupId>
      <artifactId>vaadin-cdi</artifactId>
      <version>10.0.0.beta1</version>
  </dependency>
 

If you want to start with a fresh project, the easiest option is to use the new CDI starter via vaadin.com/start.

Report issues and enhancement ideas

If you find any issues, inconveniences or improvement ideas, don’t hesitate to report them via the Vaadin CDI GitHub project! If you are looking into the code, note that the master branch is used for Vaadin Flow compatible version and Vaadin 8 compatible 3.0 is still the default branch shown in the GitHub.

Matti Tahvonen
Matti Tahvonen
Matti Tahvonen has a long history in Vaadin R&D: developing the core framework from the dark ages of pure JS client side to the GWT era and creating number of official and unofficial Vaadin add-ons. His current responsibility is to keep you up to date with latest and greatest Vaadin related technologies. You can follow him on Twitter – @MattiTahvonen
Other posts by Matti Tahvonen