[jboss-user] [JBoss Portal] - Re: How to stream a pdf at portlet?

julien@jboss.com do-not-reply at jboss.com
Thu Mar 6 04:12:42 EST 2008


"littleprince" wrote : Can you give me more detail on "Portlet 2.0 resource serving"? Some sample codes might be very helpful.

it is pretty much like a servlet.

your portlet needs to implements the ResourceServing interface with the method


  | public void serverResource(ResourceRequest req, ResourceResponse resp) throws ... {
  | 
  | resp.setContentType("application/pdf");
  | OutputStream out = resp.getPortletOutputStream();
  | ....
  | out.close();
  | 
  | }
  | 

in order to create an URL to the resource you need to use during render:


  | ResourceURL url = resp.createResourceURL();
  | 
  |   | 
  |   | The nice thing is that during resource serving you have access to the portlet request (since ResourceRequest extends PortletRequest) so you can read preferences of user and even the render parameters.
  |   | 
  |   | We have an example of resource serving here but it is for markup, not PDF:
  |   | 
  |   | http://anonsvn.jboss.org/repos/portal/modules/portlet/trunk/samples/src/main/java/org/jboss/portal/portlet/samples/remotecontroller/RemoteControllerPortlet.java

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4134489#4134489

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4134489



More information about the jboss-user mailing list