@VaadinView and @VaadinUI annotations?

Hello everyone!

I’m just learning Vaadin. Seems like I have good timing, what with the recent release of 7, but I’m also coming across a lot of things that seem to have little documentation, for example the @VaadinView and @VaadinUI annotations. I could find no documentation for them in the book of Vaadin, or the API, but the sample project I auto generated in eclipse had an @VaadinView annotation, and it looks pretty cool.

I think based on this:


that @VaadinView lets you define main “view” pages that are more easily bookmarkable. But I’m not sure if it does that, or if it does anything else.

@VaadinUI doesn’t seem to exist, and I can’t fathom what it would do if it did exist. Anyone have any idea?


The last part of the presentation you refer to cover the roadmap for the next months and beyond - not what is already in Vaadin 7. These annotations are for the Vaadin CDI add-on, of which an official beta is currently planned for sometime in March. The add-on provides dependency injection and more on servers supporting JSR-299 / JavaEE 6.

The latest Vaadin Eclipse plug-in creates a starting point for a project that you can then start to modify to add features. The Eclipse plug-in and the standard archetypes do not use these annotations in any templates, though, so I wonder how you got them into your project.

For using the Navigator etc. directly, see the tutorials
- especially the basic projects and the Navigator section if those are what you are interested in.

If you do want to try the CDI add-on, there is already a version on GitHub that you can compile yourself, but I would recommend waiting for the beta unless you already know CDI and want to do some early testing without much documentation.

I took a look and realized that the @VaadinView I’m using is a part of the Vaadin-Spring integration add-on, so I think its main purpose is that it allows me to annotate some views to be “cached=true” for a “session” scoped view.

Is the Vaadin CDI add-on you mention is really just a replacement for the Vaadin-Spring integration add-on (but more generic)?

I should probably wait until its in Beta before trying to use it, but on the other hand the documentation can’t be any less existent (the Vaadin-Spring integration has none aside from a sample project), and if your CDI can add support for Spring session scoped beans then that would be awesome. The “cached=true” is nice for my views to be faux session scoped, but I have a bunch of other classes I need to be session scoped too!

After looking at the address book project, I’ll definitely need to wait until Beta at least. I wouldn’t know how to integrate that with Spring (or if it even can be).

Spring and JavaEE 6 each provide their own context and dependency injection frameworks. Both support JSR-330 (simple injection) but for more complex IoC/CDI, they have different APIs (JSR-299 CDI in JavaEE6).

Also the Vaadin add-ons for Spring and for CDI differ in what they provide.

The various Spring add-ons require (some parts of) Spring, whereas the Vaadin CDI add-on requires either a JavaEE 6 compatible server (e.g. GlassFish 3.1, JBoss AS 7 or a recent TomEE) or a separate JSR-299 compatible CDI implementation such as Weld.

Spring and JEE6 can also be used together, but it might be simpler to stick to the APIs of one of them until you know it well enough - otherwise, it is easy to create a mess with what is configured where etc.

As for scopes, Vaadin CDI adds one custom scope: UI scope.

Thanks for the clarification. You’re right; I should just stick with Spring for now.