Vaadin CDI
Contexts and Dependency Injection for Vaadin
This add-on permits the use of primary CDI (JSR-299) features such as dependency injection, CDI events, etc. It also defines a new CDI scope for UIs and automatically configures a servlet for CDI if no Vaadin servlets are defined.
Compatibility
Vaadin CDI | Vaadin version |
---|---|
1.x | 7.x |
2.x | 8.0..8.1 |
3.x | 8.2.. |
10.0.x | 10 |
11.0.x | 14 |
Getting started
Startup
If you do not customize Vaadin Servlet in your web.xml, a CDI enabled Vaadin servlet is deployed automatically.
As UI class CdiUI is configured. If you need a custom UI class, you have to extend this class. It is not a CDI contextual instance but injects work.
Otherwise, you can customize CdiVaadinServlet just like VaadinServlet.
Component instantiation and CDI
Vaadin triggered instantiation happens in a CDI aware Vaadin Instantiator implementation. Components created by this API:
- @Route, RouteLayout, HasErrorParameter components
- component fields injected by @Id to polymer templates
By default, instantiator looks up the CDI bean by type ( component class )
and gets a contextual reference from BeanManager.
All the CDI features are usable like observer, interceptor, decorator.
When type is not found as a CDI bean ( for example ambiguous, or does not have a no-arg public constructor ), instantiation falls back to the default Vaadin behavior. On success, dependency injection is performed. Injects work, but other CDI features not. It is not a contextual instance.
Vaadin Contexts
In addition to standard CDI contexts, the CDI add-on introduces some new contexts. Read more about the supported scopes in Vaadin Docs
Services
Some Vaadin service interfaces can be implemented as a CDI bean.
- I18NProvider
- Instantiator
- SystemMessagesProvider
- ErrorHandler
Beans have to be qualified by @VaadinServiceEnabled to be picked up automatically.
Example code is available in Vaadin Docs
Vaadin Events
Following events fired as a CDI event:
- ServiceInitEvent
- PollEvent
- BeforeEnterEvent
- BeforeLeaveEvent
- AfterNavigationEvent
- UIInitEvent
- SessionInitEvent
- SessionDestroyEvent
- ServiceDestroyEvent
See example code in Vaadin Docs
Links
Compatibility
Was this helpful? Need more help?
Leave a comment or a question below. You can also join
the chat on Discord or
ask questions on StackOverflow.
Version
the official Flow CDI integration that is compatible with Vaadin 14.
- Released
- 2019-07-29
- Maturity
- STABLE
- License
- Apache License 2.0
Compatibility
- Framework
- Vaadin 14+
- Vaadin 10+ in 10.0.0
- Vaadin 8.2+ in 3.0.1
- Vaadin 7.7+ in 1.0.4
- Vaadin 8.1+ in 3.0.0.alpha1
- Vaadin 8.0+ in 2.0.0
- Vaadin 7.3+ in 1.0.5
- Vaadin 7.2+ in 1.0.0.alpha3
- Vaadin 7.0+ in 1.0.0.alpha1
- Browser
- Browser Independent
Jain I18N - Vaadin Add-on Directory
I18N (Internationalization) support or common use cases default implementation for VaadinOnline Demo
Source Code
Issue Tracker
Demo/Example Source Code
FAQ
Jain I18N version 1.0.1
Updated API to support Vaadin-7 beta3 API changes
Jain I18N version 1.0.2
Fixed Memory leak problem, available in Event handler.
Moved HAS-A relation ship logic from JainI18N to JainAssoc.
Jain I18N version 1.1.0
1). Added Annotation based Action Bar component
2). Added Annotation based Menu bar component
3). Added mising Menu bar I18N handling
Jain I18N version 1.1.1
Updated to version beta-11
Jain I18N version 1.1.2
Added Annotation based Confirmation dialog for action
Jain I18N version 1.1.3
Moved to Rc2
Jain I18N version 1.1.4
Moved to 7.0.1
Jain I18N version 1.1.6
Upgraded Vaadin Version to 7.2.1
Jain I18N version 1.1.7
Fixed An issue and Upgraded Vaadin version to 7.3.7
Jain I18N version 1.1.9
Upgraded to support 7.5