[ http://issues.apache.org/jira/browse/MYFACES-605?page=all ]
Mike Kienenberger updated MYFACES-605:
--------------------------------------
Attachment: ServletFacesContextImpl.java.patch.txt
Ok. My previous thoughts of delegating don't allow wrapping of the
ServletResponse outputStream and writer.
Here's a first-pass patch to set these values when a ServletExternalContextImpl
is set (both by the constructor and the setter). It needs a lot of review and
probably a lot of improvement, but it's better than the current broken behavior.
I duplicated the code for creating a ResponseStream and ResponseWriter from
org.apache.myfaces.renderkit.html.HtmlResponseWriterImpl. This code should
perhaps be moved into a helper class instead. Also, my patch has references
to org.apache.myfaces.renderkit.html.HtmlRendererUtils and
HtmlResponseWriterImpl in order to construct a ResponseWriter, but I don't know
a better way to do it, or even if this is inappropriate.
I have no experience with Portlets, and at first glance, I didn't see anything
that was equivalent for portlets, so maybe returning null is appropriate for a
portlet environment.
> FacesContext.getResponseStream/getResponseWriter unimplemented
> --------------------------------------------------------------
>
> Key: MYFACES-605
> URL: http://issues.apache.org/jira/browse/MYFACES-605
> Project: MyFaces
> Type: Bug
> Components: Implementation
> Versions: Nightly Build
> 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