TOP

Portlet Spring Vaadin Integration

Based on blog post from Nicolas Frankel I created the same class which works with portlets. So the method getNewApplication returns an application which is created via Spring.

import javax.portlet.PortletConfig;
import javax.portlet.PortletException;
import javax.portlet.PortletRequest;
 
import org.springframework.context.ApplicationContext;
import org.springframework.web.portlet.context.PortletApplicationContextUtils;
 
import com.vaadin.Application;
import com.vaadin.terminal.gwt.server.AbstractApplicationPortlet;
 
public class SpringApplicationPortlet extends AbstractApplicationPortlet
{
 
   private Class<? extends Application> clazz;
 
   @Override
   public void init(PortletConfig config) throws PortletException
   {
      super.init(config);
 
      ApplicationContext appContext = PortletApplicationContextUtils.getWebApplicationContext(config.getPortletContext());
 
      Application application = appContext.getBean("application", Application.class);
 
      clazz = application.getClass();
   }
 
   @Override
   protected Class<? extends Application> getApplicationClass() throws ClassNotFoundException
   {
      return clazz;
   }
 
   @Override
   protected Application getNewApplication(PortletRequest request) throws PortletException
   {
      ApplicationContext appContext = PortletApplicationContextUtils.getWebApplicationContext(request.getPortletSession()
            .getPortletContext());
 
      return appContext.getBean("application", Application.class);
   }
 
}

Leave a Reply

Your email is never published nor shared.

You may use these HTML tags and attributes:<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>


*