[jboss-user] [JBoss Portal] - Re: Downloading a File from within a Portlet.

FelderR do-not-reply at jboss.com
Fri Nov 21 10:47:53 EST 2008


Forget about the RenderResource! Just tried it out but JBoss Portal 2.7 responded with an not yet implemented Exception! 

What JSR 286 compliant container is JBoss Portal 2.7?? For my opinion it is not compliant to the JSR 286 Specification in any way!!! 

Here's the code for anyone runnning a JSF Application via the Portlet Bridge:

	public String getRenderResourceUrl() {
		Object responseObject = FacesContext.getCurrentInstance().getExternalContext().getResponse();
		if (responseObject instanceof RenderResponse) {
			RenderResponse response = (RenderResponse)responseObject;
			return response.createResourceURL().toString();
		}
		return "";
	}


to anyone else who is a native Portlet you can use:

<html xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:portlet="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd" 
xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd">
<portlet:resourceURL var="signedPdf"/>
Download file


If you are running in a JSR 168 compliant Portlet Container you can try to get access to the HttpServletRequest where you can set the ContentType: 

	public HttpServletRequest getHttpServletRequest(PortletRequest request) {
		PortletInvocation portletInvocation = (PortletInvocation) request.getAttribute(ContextDispatcherInterceptor.REQ_ATT_COMPONENT_INVOCATION);
		return portletInvocation.getDispatchedRequest();
	}

The problem with this approach is that JBoss Portal overrides the ContentType after you set it. 

For my opinion the only solution is to forward to a Servlet to handel PDF downloads! The worst solution as you do not have any access to the Portlet attributes any more. But JBoss does not offer any other solution. 

Looks to me that they ignore the fact of using JBoss Portal in real world systems. Watch out for Liferay they give you solutions for down- and uploading files.



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

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



More information about the jboss-user mailing list