portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dlest...@apache.org
Subject cvs commit: jakarta-jetspeed-2/portals-bridges/myfaces/src/java/org/apache/portals/bridges/myfaces RequestHeaderMap.java RequestHeaderValuesMap.java PortletExternalContextImpl.java FacesPortlet.java
Date Tue, 14 Sep 2004 06:47:42 GMT
dlestrat    2004/09/13 23:47:42

  Modified:    portals-bridges/myfaces/src/java/org/apache/portals/bridges/myfaces
                        PortletExternalContextImpl.java FacesPortlet.java
  Added:       portals-bridges/myfaces/src/java/org/apache/portals/bridges/myfaces
                        RequestHeaderMap.java RequestHeaderValuesMap.java
  Log:
  MyFaces tree component.
  Fixes to the MyFaces bridge.
  
  Revision  Changes    Path
  1.3       +6 -3      jakarta-jetspeed-2/portals-bridges/myfaces/src/java/org/apache/portals/bridges/myfaces/PortletExternalContextImpl.java
  
  Index: PortletExternalContextImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portals-bridges/myfaces/src/java/org/apache/portals/bridges/myfaces/PortletExternalContextImpl.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- PortletExternalContextImpl.java	11 Sep 2004 18:43:26 -0000	1.2
  +++ PortletExternalContextImpl.java	14 Sep 2004 06:47:42 -0000	1.3
  @@ -21,7 +21,6 @@
   import java.net.URL;
   import java.security.Principal;
   import java.util.Enumeration;
  -import java.util.HashMap;
   import java.util.Iterator;
   import java.util.Locale;
   import java.util.Map;
  @@ -272,10 +271,10 @@
        */
       public Map getRequestHeaderMap()
       {
  -        // TODO Hack to fix issue with MyFaces 1.0.6
           if (this.requestHeaderMap == null)
           {
  -            requestHeaderMap = new HashMap();
  +            requestHeaderMap = new RequestHeaderMap(this.portletRequest);
  +            // TODO Hack to fix issue with MyFaces 1.0.6
               requestHeaderMap.put("Content-Type", portletRequest.getResponseContentType());
           }
           return requestHeaderMap;
  @@ -286,6 +285,10 @@
        */
       public Map getRequestHeaderValuesMap()
       {
  +        if (this.requestHeaderValuesMap == null)
  +        {
  +            requestHeaderValuesMap = new RequestHeaderValuesMap(this.portletRequest);
  +        }
           return requestHeaderValuesMap;
       }
   
  
  
  
  1.3       +22 -2     jakarta-jetspeed-2/portals-bridges/myfaces/src/java/org/apache/portals/bridges/myfaces/FacesPortlet.java
  
  Index: FacesPortlet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portals-bridges/myfaces/src/java/org/apache/portals/bridges/myfaces/FacesPortlet.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- FacesPortlet.java	11 Sep 2004 18:43:26 -0000	1.2
  +++ FacesPortlet.java	14 Sep 2004 06:47:42 -0000	1.3
  @@ -57,6 +57,10 @@
   
       /** The VIEW_ID used for externalContext.getRequestServletPath(). */
       public static final String VIEW_ID = "org.apache.portals.bridges.myfaces.VIEW_ID";
  +    
  +    /** The JSF_VIEW_ID used to maintain the state of the view action. */
  +    // TODO Is this myfaces specific?
  +    public static final String JSF_VIEW_ID = "jsf_viewid";
   
       /** Name of portlet preference for Action page. */
       public static final String PARAM_ACTION_PAGE = "ActionPage";
  @@ -461,22 +465,38 @@
           PortletRequest portletRequest = (PortletRequest) facesContext.getExternalContext().getRequest();
           if (portletRequest instanceof ActionRequest)
           {
  +            String actionView = null;
  +            
  +            // Used by Myfaces (specific?) to provide the state of the current
  +            // page.  How do we know when to stay on a page or when to navigate?
  +            //if (null != portletRequest.getParameter(JSF_VIEW_ID))
  +            //{
  +            //    actionView = portletRequest.getParameter(JSF_VIEW_ID);
  +            //}
               if ((null != facesContext.getViewRoot()) && (null != facesContext.getViewRoot().getViewId()))
               {
  +                actionView = facesContext.getViewRoot().getViewId();
  +            }
  +            
  +            if (null != actionView)
  +            {
                   ((ActionResponse) facesContext.getExternalContext().getResponse()).setRenderParameter(
  -                        FacesPortlet.VIEW_ID, facesContext.getViewRoot().getViewId());
  +                        FacesPortlet.VIEW_ID, actionView);
               }
           }
           if ((portletRequest instanceof RenderRequest) && (null != portletRequest.getParameter(FacesPortlet.VIEW_ID)))
           {
               defaultView = portletRequest.getParameter(FacesPortlet.VIEW_ID);
           }
  +        
  +        // Return if we alreay have the viewid for the RenderRequest.
           if ((null != portletRequest.getAttribute(FacesPortlet.VIEW_ID))
                   && (!portletRequest.getAttribute(FacesPortlet.VIEW_ID).equals(defaultView)))
           {
               return;
           }
  -        if (facesContext.getViewRoot() == null)
  +        
  +        if (null == facesContext.getViewRoot())
           {
               facesContext.setViewRoot(new UIViewRoot());
               if (log.isDebugEnabled())
  
  
  
  1.1                  jakarta-jetspeed-2/portals-bridges/myfaces/src/java/org/apache/portals/bridges/myfaces/RequestHeaderMap.java
  
  Index: RequestHeaderMap.java
  ===================================================================
  /*
   * Copyright 2004 The Apache Software Foundation.
   * 
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   * 
   *      http://www.apache.org/licenses/LICENSE-2.0
   * 
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  package org.apache.portals.bridges.myfaces;
  
  import java.util.Enumeration;
  
  import javax.portlet.PortletRequest;
  
  /**
   * <p>
   * This must be the set of properties available via the javax.portlet.PortletRequest methods
getProperty()
   * and getPropertyNames(). As such, HTTP headers will only be included if they were provided
by the portlet container,
   * and additional properties provided by the portlet container may also be included.
   * </p>
   * <p>
   * See MyFaces project for servlet implementation.
   * </p>
   * 
   * @author <a href="dlestrat@apache.org">David Le Strat </a>
   */
  public class RequestHeaderMap extends AbstractAttributeMap
  {
      /** The portlet request. */
      private final PortletRequest portletRequest;
  
      /**
       * @param portletRequest The {@link PortletRequest}.
       */
      RequestHeaderMap(PortletRequest portletRequest)
      {
          this.portletRequest = portletRequest;
      }
      
      /**
       * @see org.apache.portals.bridges.myfaces.AbstractAttributeMap#getAttribute(java.lang.String)
       */
      protected Object getAttribute(String key)
      {
          return portletRequest.getProperty(key);
      }
  
      /**
       * @see org.apache.portals.bridges.myfaces.AbstractAttributeMap#setAttribute(java.lang.String,
java.lang.Object)
       */
      protected void setAttribute(String key, Object value)
      {
          throw new UnsupportedOperationException(
              "Cannot set PortletRequest Property");
      }
  
      /**
       * @see org.apache.portals.bridges.myfaces.AbstractAttributeMap#removeAttribute(java.lang.String)
       */
      protected void removeAttribute(String key)
      {
          throw new UnsupportedOperationException(
              "Cannot remove PortletRequest Property");
      }
  
      /**
       * @see org.apache.portals.bridges.myfaces.AbstractAttributeMap#getAttributeNames()
       */
      protected Enumeration getAttributeNames()
      {
          return portletRequest.getPropertyNames();
      }
  }
  
  
  
  1.1                  jakarta-jetspeed-2/portals-bridges/myfaces/src/java/org/apache/portals/bridges/myfaces/RequestHeaderValuesMap.java
  
  Index: RequestHeaderValuesMap.java
  ===================================================================
  /*
   * Copyright 2004 The Apache Software Foundation.
   * 
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   * 
   *      http://www.apache.org/licenses/LICENSE-2.0
   * 
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  package org.apache.portals.bridges.myfaces;
  
  import java.util.ArrayList;
  import java.util.Enumeration;
  import java.util.HashMap;
  import java.util.List;
  import java.util.Map;
  
  import javax.portlet.PortletRequest;
  
  
  /**
   * <p>
   * This must be the set of properties available via the javax.portlet.PortletRequest methods
getProperties()
   * and getPropertyNames(). As such, HTTP headers will only be included if they were provided
by the portlet
   * container, and additional properties provided by the portlet container may also be included.
   * </p>
   * <p>
   * See MyFaces project for servlet implementation.
   * </p>
   * 
   * @author <a href="dlestrat@apache.org">David Le Strat </a>
   */
  public class RequestHeaderValuesMap extends AbstractAttributeMap
  {
      /** The portlet request. */
      private final PortletRequest portletRequest;
      
      /** Value cache. */
      private final Map valueCache = new HashMap();
  
      /**
       * @param portletRequest The {@link PortletRequest}.
       */
      RequestHeaderValuesMap(PortletRequest portletRequest)
      {
          this.portletRequest = portletRequest;
      }
  
      /**
       * @see org.apache.portals.bridges.myfaces.AbstractAttributeMap#getAttribute(java.lang.String)
       */
      protected Object getAttribute(String key)
      {
          Object ret = valueCache.get(key);
          if (ret == null)
          {
              valueCache.put(key, ret = toArray(portletRequest.getProperties(key)));
          }
          return ret;
      }
  
      /**
       * @see org.apache.portals.bridges.myfaces.AbstractAttributeMap#setAttribute(java.lang.String,
java.lang.Object)
       */
      protected void setAttribute(String key, Object value)
      {
          throw new UnsupportedOperationException(
              "Cannot set PortletRequest Properties");
      }
  
      /**
       * @see org.apache.portals.bridges.myfaces.AbstractAttributeMap#removeAttribute(java.lang.String)
       */
      protected void removeAttribute(String key)
      {
          throw new UnsupportedOperationException(
              "Cannot remove PortletRequest Properties");
      }
  
      /**
       * @see org.apache.portals.bridges.myfaces.AbstractAttributeMap#getAttributeNames()
       */
      protected Enumeration getAttributeNames()
      {
          return portletRequest.getPropertyNames();
      }
  
      /**
       * @param e The enumeration.
       * @return An array of strings.
       */
      private String[] toArray(Enumeration e)
      {
          List ret = new ArrayList();
  
          while (e.hasMoreElements())
          {
              ret.add(e.nextElement());
          }
  
          return (String[]) ret.toArray(new String[ret.size()]);
      }
  }
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-dev-help@jakarta.apache.org


Mime
View raw message