ICEfaces
  1. ICEfaces
  2. ICE-2908

Add information to Developer Guide that discusses JSR-168 PortletScope and ApplicationScope

    Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.7RC1
    • Fix Version/s: None
    • Component/s: Documentation
    • Labels:
      None
    • Environment:
      N/A

      Description

      The ICEfaces Developer Guide does a fine job of discussing the potential of using Ajax Push in order to do Inter-Portlet Communication (IPC). It even goes so far as to refer the reader to the Chat portlet that is provided with ICEfaces.

      While developing the sample-icefaces-ipx-ajax-push-portlet attached to ICE-2896, I found it necessary to write a helper class like the following:

      public class PortletSessionUtil {

      public static Object getSharedSessionAttribute(FacesContext facesContext, String key) {
      PortletSession portletSession = (PortletSession)facesContext.getExternalContext().getSession(false);
      return portletSession.getAttribute(key, PortletSession.APPLICATION_SCOPE);
      }

      public static void setSharedSessionAttribute(FacesContext facesContext, String key, Object value) {
      PortletSession portletSession = (PortletSession)facesContext.getExternalContext().getSession(false);
      portletSession.setAttribute(key, value, PortletSession.APPLICATION_SCOPE);
      }

      }

      You see, when you define a managed bean in faces-config.xml using the key word "session", it actually get stored in the JSR 168 PortletSession.PortletScope. This is not a scope that is "shared" by portlets -- rather, to do that, you need to store things in PortletSession.ApplicationScope.

      Although the managed bean in the sample-icefaces-ipx-ajax-push-portlet is defined in "request" scope, it calls the utility methods above to make it possible to store shared portlet data in PortletSession.ApplicationScope

      A more elegant way to do it of course, would be if there was some kind of "portlet-session" scope that could be specified in faces-config.xml when defining the scope of a managed bean. But that's not the case right now. So for JSF 1.x and Portlet 1.0, we have to do something like the aforementioned helper class.

      Anyways, I recommend adding some information to the Developer Guide about the distinction between PortletSession.ApplicationScope and PortletSession.PortletScope in order to clarify things for the reader.

        Activity

        Neil Griffin created issue -

          People

          • Assignee:
            Unassigned
            Reporter:
            Neil Griffin
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: