myfaces-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tanju Erinmez (JIRA)" <myfaces-...@incubator.apache.org>
Subject [jira] Commented: (MYFACES-605) FacesContext.getResponseStream/getResponseWriter unimplemented
Date Fri, 30 Sep 2005 15:33:48 GMT
    [ http://issues.apache.org/jira/browse/MYFACES-605?page=comments#action_12330964 ] 

Tanju Erinmez commented on MYFACES-605:
---------------------------------------

Hi Mike,

As far as I understand the spec, the responseStream/Writer will be set in the ViewHandler
(or its delegate UIComponentTag in case of JSP) during the render phase. I might be on the
wrong track but I think the problem you have experienced was perhaps trying to generate output
within an actionListener or preRenderPhaseListener. If that's the case I think a possible
solution (though I didn't try) would be an approach where you intercept the viewroot and replace
it altogether with one custom component which in turn would then be able later to output the
desired content to the output stream.
Alternatively, you could implement a solution similar to "open new window upon click with
url which points to a download servlet". The necessary identifier would need to be generated
in a preceeding action.

I had to implement  a servlet based solution for a Portlet app which follows the latter scheme.
The outputstream in a portlet needs to deliver its html fragment wich then the portal aggregates
with others to a full html page. So there is not much room for binary content creation within
a confinement of a portlet.

HTH,
Tanju 

> FacesContext.getResponseStream/getResponseWriter unimplemented
> --------------------------------------------------------------
>
>          Key: MYFACES-605
>          URL: http://issues.apache.org/jira/browse/MYFACES-605
>      Project: MyFaces
>         Type: Bug
>   Components: Implementation
>     Versions: 1.1.1
>     Reporter: Mike Kienenberger
>  Attachments: ServletFacesContextImpl.java.patch.txt
>
> I'm trying to generate a downloadable file link, and I'm using:
>         FacesContext facesContext = FacesContext.getCurrentInstance();
>         OutputStream responseStream = facesContext.getResponseStream();
> but responseStream is coming back null.
> A search through the code seems to indicate that the only thing to call ServletFacesContextImpl.setResponseStream
is FacesContextWrapper.setResponseStream(), and nothing calls this method.
> The same thing appears to be true for responseWriter.
> It looks like these methods should be delegating to the ExternalContext rather than holding
local copies of the values, especially since the external context has valid references.
> facesContext= ServletFacesContextImpl  (id=117)
> 	_externalContext= ServletExternalContextImpl  (id=122)
> 		_servletResponse= ExtensionsResponseWrapper  (id=157)
> 			printWriter= null
> 			response= ServletHttpResponse  (id=165)
> 			stream= ByteArrayOutputStream  (id=167)
> 	_renderResponse= false
> 	_responseComplete= false
> 	_responseStream= null
> 	_responseWriter= null
> However, I'm not sure the best way of doing this.   One way would be to typecast ExternalContext
to either a ServletExternalContextImpl or a PortletExternalContextImpl and follow the chain
of objects.
> I can create a patch to do this if there's confirmation that this is the best way to
go about it.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


Mime
View raw message