[ http://issues.apache.org/jira/browse/MYFACES-123?page=comments#action_60595 ] Stan Silvert commented on MYFACES-123: --------------------------------------
Actually, I found that it wasn't a problem with a new code change. It looks like UIComponentTag has not been changed in quite a while. The problem was that Derek and I were both trying MyFaces on a new portlet implementation (JBoss Portal) which caused a different execution path that hit this problem. Still, the problem in MyFaces needs to be fixed ASAP. Now that we have portlet support we can't assume that the underlying request is a ServletRequest. > UIComponentTag breaks Portlet support: ClassCastException > --------------------------------------------------------- > > Key: MYFACES-123 > URL: http://issues.apache.org/jira/browse/MYFACES-123 > Project: MyFaces > Type: Bug > Versions: Nightly Build > Reporter: Stan Silvert > Priority: Blocker > > UIComponentTag now has code that calls ExternalContext.getRequest() and then > casts the result to a ServletRequest. In a portal environment, the > underlying request is not an instance of ServletRequest, so you get a > ClassCastException. > Here is the offending code from the setupResponseWriter() method in > UIComponentTag: > ServletRequest request = > (ServletRequest)facesContext.getExternalContext().getRequest(); > _writer = renderKit.createResponseWriter(new > _PageContextOutWriter(pageContext), > request.getContentType(), //TODO: is > this the correct content type? > request.getCharacterEncoding()); > I see two ways to fix this: > 1) Just pass nulls to createResponseWriter instead of getting content type > and char encoding from the request. This is allowed under the JSF API, but > I'm not sure if it is what you want. > 2) Call PortletUtil.isRenderResponse(FacesContext) to find out if we are in a > portlet environment. Then use the Portlet API or Servlet API to get the > content type and char encoding. For portlet, you would need to use the > RenderResponse like this: > if (PortletUtil.isRenderResponse(facesContext)) > { > RenderResponse response = > (RenderResponse)facesContext.getExternalContext().getResponse(); > response.getContentType(); > response.getCharacterEncoding(); > } > Overall, I think we should use #1 if it will work. -- 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 - If you want more information on JIRA, or have a bug to report see: http://www.atlassian.com/software/jira
