> > _writer = renderKit.createResponseWriter(new
> > _PageContextOutWriter(pageContext),
> >                     pageContext.getRequest().getContentType(),
> >                     pageContext.getRequest().getCharacterEncoding());
> >

To share with everyone, the reason we've been having a hard time figuring out 
how to fix this is that we were getting the request from the ExternalContext.  
Then, we have to figure out whether that request is a servlet request or a 
portlet request.  We can't use instanceof because that would put a run-time 
dependency on the portlet API (which we don't want if we are not running in a 
portlet).

Getting the request from the pageContext insures that the request will always 
be a ServletRequest because it comes from the JSP instead of the 
ExternalContext.  The question I have now is, "Will the content type and 
character encoding be correct if we get it from the PageContext.

Stan Silvert
JBoss, Inc.
[EMAIL PROTECTED]
callto://stansilvert

> -----Original Message-----
> From: Stan Silvert [mailto:[EMAIL PROTECTED]
> Sent: Monday, March 14, 2005 8:42 AM
> To: MyFaces Development
> Subject: RE: Problem with portlet integration (ClassCastException)
> 
> This is a known issue already logged in Jira, (MYFACES-123).  Matthias,
> Manfred, and myself have been trying to figure out the best way to fix it.
> 
> Actually, I like your solution.  I'll look at it further.  Thanks for the
> input.
> 
> Stan Silvert
> JBoss, Inc.
> [EMAIL PROTECTED]
> callto://stansilvert
> > -----Original Message-----
> > From: B�hringer Jochen [mailto:[EMAIL PROTECTED]
> > Sent: Monday, March 14, 2005 6:24 AM
> > To: [email protected]
> > Subject: Problem with portlet integration (ClassCastException)
> >
> > Hi,
> >
> > I tried to run my JSF Application as a portlet (using the latest myfaces
> > version built directly from CVS yesterday). But I got a
> ClassCastException
> > in UIComponentTag.setupResponseWriter()
> >
> > In this line: ServletRequest request =
> > (ServletRequest)facesContext.getExternalContext().getRequest();
> >
> > Because getRequest does not return a ServletRequest in a portlet
> > environment. The request variable is used in the next line to determine
> > the contentType and characterEncoding for the response writer.
> >
> > So I deleted the line above and determined the characterEncoding and
> > contentType using the pageContext instance variable.
> >
> > _writer = renderKit.createResponseWriter(new
> > _PageContextOutWriter(pageContext),
> >                     pageContext.getRequest().getContentType(),
> >                     pageContext.getRequest().getCharacterEncoding());
> >
> >
> > Now it works. But this was the first time I looked into the myfaces
> > sources. So I'm not sure if this might have any side effects.
> >
> > Should I open a bug on this?
> >
> > Thx
> > Jochen

Reply via email to