How to use Injection from Java EE 6 on Vaadin Portlets

Platform:

  • Liferay 6.0.* runnig on GlassFish 3.1.*
  • Vaadin 6.6.*

The documentation
Creating JEE6 Vaadin Applications
, references CDI but does not work with Vaadin Porlets.

In order for this to work, we can adapt the steps described in section “Option 2: Use Context and Dependency Injection (CDI)”

  • Remove annotation @SessionScoped() from Vaadin Application
  • Use the Vaadin Portlet Class “com.vaadin.terminal.gwt.server.ApplicationPortlet” (instead of com.vaadin.terminal.gwt.server.ApplicationPortlet2). In portlet deployment descriptor (portlet.xml) we will have something like

    <portlet-class>com.vaadin.terminal.gwt.server.ApplicationPortlet</portlet-class>
    <init-param>
        <name>application</name>
        <value><!-- Replace this with the a valid URI for Created Vaddin Application Servlet  --></value>
    </init-param>