2 Replies Latest reply on May 31, 2005 4:24 PM by sgwood

    Opening up ActionResponseImpl

      After riding the JBoss portal learning curve (yes, Julien, I am still hanging in there!), I have successfully integrated JPivot (an OLAP UI) as a portlet. The only change I needed to JBoss Portal was to ActionResponseImpl, and I would like some feedback about whether this is a legitimate change that should be done to the base JBoss Portal code, or whether this should have been done another way.

      I used the portlet bridge to get access to the HttpServletRequest and Response that the base JPivot code needed. Because of this, I had to have my JPivot portlet subclass GenericPortlet.

      JPivot dynamically generates graphics (PNGs), PDFs and Excel files, sending a stream to the browser. Looking at the CMSPortlet, I saw the processAction method sending streams, ie.:

      resp.sendBytes(contentType, content.getBytes());


      This was not available to GenericPortlet subclasses which have an ActionResponse, not a JBossActionResponse, which implements sendBytes. The way I worked around this was to add a setResult(Result aResult) method to ActionResponseImpl and use it as follows:

      PortletResponse portletResponse;
      ByteArrayOutputStream baos = new ByteArrayOutputStream(16384);
      
      ...
      // Fill up baos
      
      ActionResponseImpl responseImpl = (ActionResponseImpl) portletResponse;
      org.jboss.portal.server.output.Result portletResult = new org.jboss.portal.server.output.StreamResult(windowCtx, contentType, baos.toByteArray());
      responseImpl.setResult(portletResult);
      



      Was there a better way to do this? This could be some other method I don't know about, or maybe implement sendBytes on ActionResponseImpl.

      If not, can the ActionResponseImpl.setResult method be implemented in base JBoss Portal?


      Thanks,


      Sherman