You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Jan Peter Stotz (JIRA)" <de...@myfaces.apache.org> on 2006/08/28 12:58:23 UTC

[jira] Created: (MYFACES-1394) ViewTag makes wrong class cast when using locale attribute

ViewTag makes wrong class cast when using locale attribute
----------------------------------------------------------

                 Key: MYFACES-1394
                 URL: http://issues.apache.org/jira/browse/MYFACES-1394
             Project: MyFaces Core
          Issue Type: Bug
          Components: Portlet_Support
    Affects Versions: 1.1.5-SNAPSHOT
         Environment: Java 1.5.0.06 + JBoss Portal Server 2.2.1-SP3
            Reporter: Jan Peter Stotz
         Attachments: Stacktrace.txt

When using JSF inside a portlet the locale attribute of the view-tag can not be used because a ClassCastException is thrown. 
This is because ViewTag.setProperties(UIComponent component) assumes that getFacesContext().getExternalContext().getRequest() returns a javax.servlet.ServletRequest which is only correct for non-portlets. For portlets it returns an javax.portlet.PortletRequest which can not be casted to javax.servlet.ServletRequest. 

See also:
http://java.sun.com/javaee/javaserverfaces/1.0/docs/api/javax/faces/context/ExternalContext.html#getRequest()

-- 
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

        

[jira] Commented: (MYFACES-1394) ViewTag makes wrong class cast when using locale attribute

Posted by "Michael Lahr (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/MYFACES-1394?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12465201 ] 

Michael Lahr commented on MYFACES-1394:
---------------------------------------

According to the JavaServer Faces Specification, Chapter 9.2.8, the use of the jstl tag fmt:setLocale is discouraged.
IMHO this would also apply to the setting of the javax.servlet.jsp.jstl.core.Config.FMT_LOCALE attribute inside
ViewTag, which causes this ClassCastException.
Thus it appears that a specification compliant solution would be to simply eliminate the code in question which reads
            Config.set((ServletRequest)getFacesContext().getExternalContext().getRequest(),
                       Config.FMT_LOCALE,
                       locale);
at lines 238-240 in ViewTag.java

> ViewTag makes wrong class cast when using locale attribute
> ----------------------------------------------------------
>
>                 Key: MYFACES-1394
>                 URL: https://issues.apache.org/jira/browse/MYFACES-1394
>             Project: MyFaces Core
>          Issue Type: Bug
>          Components: Portlet_Support
>    Affects Versions: 1.1.5-SNAPSHOT
>         Environment: Java 1.5.0.06 + JBoss Portal Server 2.2.1-SP3
>            Reporter: Jan Peter Stotz
>         Attachments: Stacktrace.txt
>
>
> When using JSF inside a portlet the locale attribute of the view-tag can not be used because a ClassCastException is thrown. 
> This is because ViewTag.setProperties(UIComponent component) assumes that getFacesContext().getExternalContext().getRequest() returns a javax.servlet.ServletRequest which is only correct for non-portlets. For portlets it returns an javax.portlet.PortletRequest which can not be casted to javax.servlet.ServletRequest. 
> See also:
> http://java.sun.com/javaee/javaserverfaces/1.0/docs/api/javax/faces/context/ExternalContext.html#getRequest()

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