ICEfaces
  1. ICEfaces
  2. ICE-2277

SessionMap doesnt contain portlet session data

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: 1.7DR#2
    • Fix Version/s: 1.7DR#3, 1.7
    • Component/s: Framework
    • Labels:
      None
    • Environment:
      Tomcat 6.0.14 Liferay 4.3.3 ICEFaces 1.7.0 DR2

      Description

      This code works in ICEFaces 1.6, but fails in 1.7-DR2

      FacesContext facesContext = FacesContext.getCurrentInstance();
              Map s = facesContext.getExternalContext().getSessionMap();

                  if (s != null)
                  {
                      m_lastLocale = (Locale) s.get( "org.apache.struts.action.LOCALE");
                      System.out.println("LOCALE:"+m_lastLocale);
                  }


      I use this code to determine the current language setting in Liferay using the
      Language Portlet to add the locale object to the session.
      It returns null in DR2.

        Activity

        Hide
        Deryk Sinotte added a comment -

        We must have been exposing this information incorrectly in previous versions. According to the JSF API documentation for getSessionMap() in a portlet environment:

        "Portlet: This must be the set of attributes available via the javax.portlet.PortletSession methods getAttribute(), getAttributeNames(), removeAttribute(), and setAttribute(). All session attribute access must occur in PORTLET_SCOPE scope within the session."

        The issue here is that there are some session attributes that are APPLICATION_SCOPE and "org.apache.struts.action.LOCALE" is one of those. Fortunately there is a work-around. Instead of getting the sessionMap(), you can get the session directly and use it's more direct API to get at APPLICATION_SCOPE session attributes. For example (minus the error checking and such):

        Object sessObj = exContext.getSession(false);
        PortletSession sess = (PortletSession) sessObj;
        locale = (Locale) sess.getAttribute(localeKey, PortletSession.APPLICATION_SCOPE);

        So resolving this as Won't Fix.

        Show
        Deryk Sinotte added a comment - We must have been exposing this information incorrectly in previous versions. According to the JSF API documentation for getSessionMap() in a portlet environment: "Portlet: This must be the set of attributes available via the javax.portlet.PortletSession methods getAttribute(), getAttributeNames(), removeAttribute(), and setAttribute(). All session attribute access must occur in PORTLET_SCOPE scope within the session." The issue here is that there are some session attributes that are APPLICATION_SCOPE and "org.apache.struts.action.LOCALE" is one of those. Fortunately there is a work-around. Instead of getting the sessionMap(), you can get the session directly and use it's more direct API to get at APPLICATION_SCOPE session attributes. For example (minus the error checking and such): Object sessObj = exContext.getSession(false); PortletSession sess = (PortletSession) sessObj; locale = (Locale) sess.getAttribute(localeKey, PortletSession.APPLICATION_SCOPE); So resolving this as Won't Fix.
        Hide
        Mike Lawrence added a comment -

        This also fails on 1.6.2

        Show
        Mike Lawrence added a comment - This also fails on 1.6.2

          People

          • Assignee:
            Unassigned
            Reporter:
            Mike Lawrence
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: