Vaadin 7 + CDI = vaadin-cdi-integration ??

Anybody utilizing this CDI integration project? The README on github only explains how to build the project, but not how to make use of it. This CDI integration looks promising, but there is currently no documentation to integrate this jar in our project. It appears a number of Vaadin team members are working on this, so any details they can add in integrating this project with an EE 6 app would be awesome.


https://github.com/vaadin/vaadin-cdi-integration

Otherwise, I assume it’s a matter of reverse engineering their test suite to figure out how to integrate this in our own WAR.

We are evaluating Vaadin 7 for our company’s HTML 5 solution - which must integrate with EE 6 backend, so I any help from Vaadin community is greatly appreciated!

Vaadin-cdi-integration in Github is indeed the official CDI integration for Vaadin 7 framework. The project is not yet officially released in Vaadin.com and currently it’s mostly tested internally and by the community members like yourself.

I will provide small tutorial and documentation to get everyone started. Currently the easiest way is to add the jar to your classpath and annotate Vaadin UI class with @VaadinUI annotation. This simply makes the UI managed bean allowing further injections to it. If the UI is the only UI within your project, and you want to access is directly through context path of your Vaadin application, also add the @Root annotation for the UI.

Vaadin-cdi-integration comes with ContextDeloyer mechanism allowing configuration based only on annotations. This way it’s possible not to use web.xml deployment descriptor at all for example. If you want to try out the cdi-integration, remember to add the empty beans.xml file to your project, otherwise beans are not usable within your project.

Please keep in mind that vaadin-cdi-integration is currently not released, not feature ready and most likely has lot of tuning to be done so the current state does not represent the final quality. Feedback is of course most welcome.

CDI is kindof essensial to enterprise applications, and development of this important part of Vaadin seems to have stopped?

Hi, the cdi-integration as in pretty good shape actually and its development sure isn’t dead. Our R&D department has just been busy elsewhere, but a team is about to start on it as soon as they get another largish product renewal out. It was supposed to happen this week, but you know the software industry…

By my gut feeling, this kind of integrations are nowdays better valued here at Vaadin. That is a good thing IMO. If you like Spring you should definitely follow
this effort
by our Petter Holmström and Josh Long from Pivotal.

cheers,
matti

Hehe, the last week of any project usually is pretty long, yes … :o) Spring is nice, but I figured I’d just go with plain JEE7 and Wildfly, so I got a bit spooked by the alpha-state of vaadin-cdi. Seems to work nicely, though … but updates are alwyas welcome :slight_smile:

The largest issue in the current Vaadin CDI integration: nobody dares to try it because it is called “alpha” :slight_smile:

Seriously, if you have found out some room for improvements, please, let us know via
dev.vaadin.com
.

cheers,
matti

Matti,
I have followed the youtube video you did with Geertjan regarding JEE7 development with NetBeans and Vaadin, and I haven’t been able to get past the injection of the facades into the views. I am getting NPEs whenever I try to access the injected class. You make use of an initComponent() function in your view class, which has the @PostConstruct annotation, but I don’t see where you are calling that initComponent() method anywhere. I have this feeling I’m missing something very basic in either my setup (using the NetBeans plugin for Vaadin, BTW), or my understanding of how CDI works in Vaadin.

Hi,

Are you using Vaadin CDI plugin and injected UIs/Views? If you use Vaadin CDI add-on properly, it will inject your Views and/or UIs. Only “managed” beans can use @Inject.

Here are two example projects that you can use as a starting point:

cheers,
matti

It appears that the only thing I was missing was the @Inject CDIViewProvider. Once I added that everything seems to be working. Thanks.

Good to hear you got it working. “Injection chain” must not be broken and don’t use injected stuff in constructor are my basic rules when working with CDI.

cheers,
matti

Just to answer your previous point, methods annotated with @PostConstuct are invoked by the container after the class is instantiated.They’re called once (and only once), after all dependencies have been injected, and you can utilise this to access depencies knowing they’ve been successfully injected.