You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Kito D. Mann (JIRA)" <in...@incubator.apache.org> on 2005/03/10 02:27:54 UTC

[jira] Commented: (MYFACES-123) UIComponentTag breaks Portlet support: ClassCastException

     [ http://issues.apache.org/jira/browse/MYFACES-123?page=comments#action_60551 ]
     
Kito D. Mann commented on MYFACES-123:
--------------------------------------

Stan,

Any idea why things still seem to work with this bug?

Kito D. Mann 
Author, JavaServer Faces in Action
http://www.JSFCentral.com - JSF FAQ, news, and info

Are you using JSF in a project? Send an e-mail to trenches@jsfcentral.com and you could win a free copy of JavaServer Faces in Action!


> 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


Re: [jira] Commented: (MYFACES-123) UIComponentTag breaks Portlet support: ClassCastException

Posted by Derek Shen <de...@gmail.com>.
It is introduced by some new code change with MyFaces. Stan told me
that without the fix, the portlet support in MyFaces will not work on
any portal.

On Thu, 10 Mar 2005 02:27:54 +0100 (CET), Kito D. Mann (JIRA)
<in...@incubator.apache.org> wrote:
>     [ http://issues.apache.org/jira/browse/MYFACES-123?page=comments#action_60551 ]
> 
> Kito D. Mann commented on MYFACES-123:
> --------------------------------------
> 
> Stan,
> 
> Any idea why things still seem to work with this bug?
> 
> Kito D. Mann
> Author, JavaServer Faces in Action
> http://www.JSFCentral.com - JSF FAQ, news, and info
> 
> Are you using JSF in a project? Send an e-mail to trenches@jsfcentral.com and you could win a free copy of JavaServer Faces in Action!
> 
> > 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
> 
>