You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by mf...@apache.org on 2008/04/16 19:36:58 UTC

svn commit: r648766 - in /myfaces/portlet-bridge/core/branches/sobryan-PortletBridge20-patched: api/src/main/resources/META-INF/ impl/src/main/java/org/apache/myfaces/portlet/faces/application/ impl/src/main/java/org/apache/myfaces/portlet/faces/bridge...

Author: mfreedman
Date: Wed Apr 16 10:36:55 2008
New Revision: 648766

URL: http://svn.apache.org/viewvc?rev=648766&view=rev
Log:
Latest updates to keep scotts patch branch in sync as I put fixes in for him.

Added:
    myfaces/portlet-bridge/core/branches/sobryan-PortletBridge20-patched/api/src/main/resources/META-INF/portlet2.0-bridge-faces1.2-faces-config-extensions.xsd
    myfaces/portlet-bridge/core/branches/sobryan-PortletBridge20-patched/impl/src/main/java/org/apache/myfaces/portlet/faces/application/PortletViewHandlerResponseWrapper.java
Modified:
    myfaces/portlet-bridge/core/branches/sobryan-PortletBridge20-patched/impl/src/main/java/org/apache/myfaces/portlet/faces/application/PortletViewHandlerImpl.java
    myfaces/portlet-bridge/core/branches/sobryan-PortletBridge20-patched/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeImpl.java
    myfaces/portlet-bridge/core/branches/sobryan-PortletBridge20-patched/impl/src/main/java/org/apache/myfaces/portlet/faces/util/config/FacesConfigurationProcessor.java

Added: myfaces/portlet-bridge/core/branches/sobryan-PortletBridge20-patched/api/src/main/resources/META-INF/portlet2.0-bridge-faces1.2-faces-config-extensions.xsd
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/branches/sobryan-PortletBridge20-patched/api/src/main/resources/META-INF/portlet2.0-bridge-faces1.2-faces-config-extensions.xsd?rev=648766&view=auto
==============================================================================
--- myfaces/portlet-bridge/core/branches/sobryan-PortletBridge20-patched/api/src/main/resources/META-INF/portlet2.0-bridge-faces1.2-faces-config-extensions.xsd (added)
+++ myfaces/portlet-bridge/core/branches/sobryan-PortletBridge20-patched/api/src/main/resources/META-INF/portlet2.0-bridge-faces1.2-faces-config-extensions.xsd Wed Apr 16 10:36:55 2008
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Created with Liquid XML Studio 1.0.8.0 (http://www.liquid-technologies.com) -->
+<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://myfaces.apache.org/portletbridge" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+  <xs:element name="excluded-attributes">
+    <xs:complexType>
+      <xs:sequence>
+        <xs:element minOccurs="0" maxOccurs="unbounded" name="excluded-attribute" type="xs:string" />
+      </xs:sequence>
+    </xs:complexType>
+  </xs:element>
+  <xs:element name="public-parameter-mappings">
+    <xs:complexType>
+      <xs:sequence>
+        <xs:element minOccurs="0" maxOccurs="unbounded" name="public-parameter-mapping" type="parameter-mappingType" />
+      </xs:sequence>
+    </xs:complexType>
+  </xs:element>
+  <xs:complexType name="parameter-mappingType">
+    <xs:sequence>
+      <xs:element name="parameter" type="xs:string" />
+      <xs:element name="model-el" type="xs:string" />
+    </xs:sequence>
+  </xs:complexType>
+</xs:schema>
\ No newline at end of file

Modified: myfaces/portlet-bridge/core/branches/sobryan-PortletBridge20-patched/impl/src/main/java/org/apache/myfaces/portlet/faces/application/PortletViewHandlerImpl.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/branches/sobryan-PortletBridge20-patched/impl/src/main/java/org/apache/myfaces/portlet/faces/application/PortletViewHandlerImpl.java?rev=648766&r1=648765&r2=648766&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/branches/sobryan-PortletBridge20-patched/impl/src/main/java/org/apache/myfaces/portlet/faces/application/PortletViewHandlerImpl.java (original)
+++ myfaces/portlet-bridge/core/branches/sobryan-PortletBridge20-patched/impl/src/main/java/org/apache/myfaces/portlet/faces/application/PortletViewHandlerImpl.java Wed Apr 16 10:36:55 2008
@@ -594,9 +594,9 @@
       int tildeIdx = mBuilder.indexOf(SAVESTATE_FIELD_MARKER);
       while (tildeIdx > 0)
       {
-        writer.write(mBuilder.substring(pos, (tildeIdx - pos)));
+        writer.write(mBuilder.substring(pos, tildeIdx));
         stateManager.writeState(mContext, stateToWrite);
-        pos += tildeIdx + markLen;
+        pos = tildeIdx + markLen;
         tildeIdx = mBuilder.indexOf(SAVESTATE_FIELD_MARKER, pos);
       }
       writer.write(mBuilder.substring(pos));

Added: myfaces/portlet-bridge/core/branches/sobryan-PortletBridge20-patched/impl/src/main/java/org/apache/myfaces/portlet/faces/application/PortletViewHandlerResponseWrapper.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/branches/sobryan-PortletBridge20-patched/impl/src/main/java/org/apache/myfaces/portlet/faces/application/PortletViewHandlerResponseWrapper.java?rev=648766&view=auto
==============================================================================
--- myfaces/portlet-bridge/core/branches/sobryan-PortletBridge20-patched/impl/src/main/java/org/apache/myfaces/portlet/faces/application/PortletViewHandlerResponseWrapper.java (added)
+++ myfaces/portlet-bridge/core/branches/sobryan-PortletBridge20-patched/impl/src/main/java/org/apache/myfaces/portlet/faces/application/PortletViewHandlerResponseWrapper.java Wed Apr 16 10:36:55 2008
@@ -0,0 +1,184 @@
+/* Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.myfaces.portlet.faces.application;
+
+import java.lang.IllegalArgumentException;
+import java.io.ByteArrayOutputStream;
+import java.io.CharArrayWriter;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+
+import java.io.UnsupportedEncodingException;
+
+import java.nio.ByteBuffer;
+
+import java.util.Locale;
+
+import javax.portlet.RenderResponse;
+import javax.portlet.filter.RenderResponseWrapper;
+
+import javax.servlet.http.HttpServletResponse;
+
+public class PortletViewHandlerResponseWrapper
+  extends RenderResponseWrapper
+{
+
+  private ByteArrayOutputStream mByteStream;
+  private CharArrayWriter mCharWriter;
+  private PrintWriter mPrintWriter;
+  private int mBufSize = 4096;
+  private Locale mLocale = null;
+
+  public PortletViewHandlerResponseWrapper(RenderResponse wrapped)
+  {
+    super(wrapped);
+  }
+  
+  public PortletViewHandlerResponseWrapper(RenderResponse wrapped, Locale locale)
+  {
+    this(wrapped);
+    mLocale = locale;
+  }
+  
+  public OutputStream getPortletOutputStream()
+    throws IOException
+  {
+    if (mPrintWriter != null)
+    {
+      throw new IllegalStateException();
+    }
+    if (mByteStream == null)
+    {
+      mByteStream = new ByteArrayOutputStream(mBufSize);
+    }
+    return mByteStream;
+  }
+
+  public PrintWriter getWriter()
+    throws IOException
+  {
+    if (mByteStream != null)
+    {
+      throw new IllegalStateException();
+    }
+    if (mPrintWriter == null)
+    {
+      mCharWriter = new CharArrayWriter(mBufSize);
+      mPrintWriter = new PrintWriter(mCharWriter);
+    }
+
+    return mPrintWriter;
+  }
+
+
+  public boolean isBytes()
+  {
+    return (mByteStream != null);
+  }
+
+  public boolean isChars()
+  {
+    return (mCharWriter != null);
+  }
+
+  public byte[] getBytes()
+  {
+    if (isBytes())
+    {
+      return mByteStream.toByteArray();
+    }
+    else
+    {
+      return null;
+    }
+  }
+
+  public char[] getChars()
+  {
+    if (isChars())
+    {
+      return mCharWriter.toCharArray();
+    }
+    else if (mLocale != null)
+    {
+      try
+      {
+        String enc = mLocale.toString();
+        String str = mByteStream.toString(enc);
+        return str.toCharArray();
+      }
+      catch (UnsupportedEncodingException e)
+      {
+        return mByteStream.toString().toCharArray();
+      }
+    } 
+    else
+    {
+      return mByteStream.toString().toCharArray();
+    }
+  }
+  
+  public void setBufferSize(int size)
+    throws IllegalStateException
+  {
+    if (mPrintWriter != null || mByteStream != null)
+      throw new IllegalArgumentException();
+    
+    mBufSize = size;
+  }
+  
+  public void flushBuffer()
+    throws IOException
+  {
+    RenderResponse parent = super.getResponse();
+    PrintWriter writer = parent.getWriter();
+    
+    writer.print(getChars());
+    writer.flush();
+  }
+  
+  public void reset()
+  {
+    super.reset();
+    resetInternal();
+  }
+  
+  private void resetInternal()
+  {
+    if (mCharWriter != null)
+    {
+      mCharWriter.reset();
+    }
+    
+    if (mByteStream != null)
+    {
+      mByteStream.reset();
+    }
+  }
+  
+  public void resetBuffer()
+  {
+    super.resetBuffer();
+    resetInternal();
+  }
+
+  // end of class BridgeRenderFilterResponseWrapper
+}

Modified: myfaces/portlet-bridge/core/branches/sobryan-PortletBridge20-patched/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeImpl.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/branches/sobryan-PortletBridge20-patched/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeImpl.java?rev=648766&r1=648765&r2=648766&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/branches/sobryan-PortletBridge20-patched/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeImpl.java (original)
+++ myfaces/portlet-bridge/core/branches/sobryan-PortletBridge20-patched/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeImpl.java Wed Apr 16 10:36:55 2008
@@ -321,7 +321,13 @@
 
         finalizeActionResponse(context);
       }
-
+      else
+      {
+        // remove the redirect attr so its not carried over to the 
+        // render in environments in which action/render are run in the
+        // same request ctx.
+        context.getExternalContext().getRequestMap().remove(BridgeImpl.BRIDGE_REDIRECT_VIEWPARAMS);
+      }
 
     }
     catch (Exception e)

Modified: myfaces/portlet-bridge/core/branches/sobryan-PortletBridge20-patched/impl/src/main/java/org/apache/myfaces/portlet/faces/util/config/FacesConfigurationProcessor.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/branches/sobryan-PortletBridge20-patched/impl/src/main/java/org/apache/myfaces/portlet/faces/util/config/FacesConfigurationProcessor.java?rev=648766&r1=648765&r2=648766&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/branches/sobryan-PortletBridge20-patched/impl/src/main/java/org/apache/myfaces/portlet/faces/util/config/FacesConfigurationProcessor.java (original)
+++ myfaces/portlet-bridge/core/branches/sobryan-PortletBridge20-patched/impl/src/main/java/org/apache/myfaces/portlet/faces/util/config/FacesConfigurationProcessor.java Wed Apr 16 10:36:55 2008
@@ -26,8 +26,11 @@
 
 import java.util.ArrayList;
 import java.util.Enumeration;
+import java.util.HashMap;
 import java.util.List;
 
+import java.util.Map;
+
 import javax.portlet.PortletContext;
 
 import javax.xml.parsers.SAXParser;
@@ -46,6 +49,7 @@
   private static final String FACES_CONFIG_METAINF_PATH = "META-INF/faces-config.xml";
   private static final String FACES_CONFIG_WEBINF_PATH = "/WEB-INF/faces-config.xml";
   private List<String> mExcludedAttributes = null;
+  private Map<String, String> mPublicParameterMappings = null;
 
   /**
    * <p>
@@ -63,12 +67,17 @@
     {
       scanForFacesMappings(context);
     }
-  } // END WebXmlProcessor
+  } 
 
   public List<String> getExcludedAttributes()
   {
     return mExcludedAttributes;
-  } // END getFacesMappings
+  } 
+  
+  public Map<String,String> getPublicParameterMappings()
+  {
+    return mPublicParameterMappings;
+  }
 
   /**
    * <p>
@@ -163,18 +172,31 @@
     private static final String APP_EXTENSION_ELEMENT     = "application-extension";
     private static final String EXCLUDED_ATTRIBUTES_ELEMENT    = "excluded-attributes";
     private static final String EXCLUDED_ATTRIBUTE_ELEMENT  = "excluded-attribute";
+    private static final String PUBLIC_PARAMETER_MAPPINGS_ELEMENT  = "public-parameter-mappings";
+    private static final String PUBLIC_PARAMETER_MAPPING_ELEMENT  = "public-parameter-mapping";
+    private static final String PARAMETER_ELEMENT  = "parameter";
+    private static final String MODEL_EL_ELEMENT  = "model-el";
+
 
     private boolean             mInApplicationElement        = false;
     private boolean             mInApplicationExtensionElement    = false;
     private boolean             mInExcludedAttributesElement   = false;
+    private boolean             mInPublicParameterMappings = false;
+    private boolean             mInPublicParameterMapping = false;
+    private boolean             mInParameter = false;
+    private boolean             mInModelEL = false;
+    
    
     private StringBuilder       mContent;
+    private String              mContent1;
+    private String              mContent2;
 
 
     public void reset()
     {
       mInApplicationElement = mInApplicationExtensionElement =
-        mInExcludedAttributesElement = false;
+        mInExcludedAttributesElement = mInPublicParameterMappings =
+        mInPublicParameterMapping = mInParameter = mInModelEL = false;
     }
 
     @Override
@@ -202,6 +224,23 @@
       {
           mInExcludedAttributesElement = true;
       }
+      else if (PUBLIC_PARAMETER_MAPPINGS_ELEMENT.equals(localName))
+      {
+        mInPublicParameterMappings = true;
+      }
+      else if (PUBLIC_PARAMETER_MAPPING_ELEMENT.equals(localName))
+      {
+        mInPublicParameterMapping = true;
+      }
+      else if (PARAMETER_ELEMENT.equals(localName) || 
+               MODEL_EL_ELEMENT.equals(localName))
+      {
+        if (mInApplicationElement && mInApplicationExtensionElement &&
+          mInPublicParameterMappings && mInPublicParameterMapping)
+        {
+          mContent = new StringBuilder();
+        }
+      }
       else if (EXCLUDED_ATTRIBUTE_ELEMENT.equals(localName))
       {
         if (mInApplicationElement && mInApplicationExtensionElement &&
@@ -254,6 +293,40 @@
         {
           mExcludedAttributes.add(excludedAttribute);
         }
+      }
+      else if (PUBLIC_PARAMETER_MAPPINGS_ELEMENT.equals(localName))
+      {
+        mInPublicParameterMappings = false;
+      }
+      else if (PUBLIC_PARAMETER_MAPPING_ELEMENT.equals(localName))
+      {
+        if (mContent1 != null && mContent2 != null)
+        {
+          if (mPublicParameterMappings == null)
+          {
+            mPublicParameterMappings = (Map<String, String> )new HashMap(5);
+          }
+          
+          if (!mPublicParameterMappings.containsKey(mContent1))
+          {
+            mPublicParameterMappings.put(mContent1, mContent2);
+          }
+        }
+        mContent1 = mContent2 = null;
+
+        mInPublicParameterMappings = false;
+      } 
+      else if (PARAMETER_ELEMENT.equals(localName) && mContent != null
+        && mContent.length() > 0)
+      {
+        // hold mContent to add as pair later
+        mContent1 = mContent.toString().trim();
+      }
+      else if (MODEL_EL_ELEMENT.equals(localName) && mContent != null
+        && mContent.length() > 0)
+      {
+        // hold mContent to add as pair later
+        mContent2 = mContent.toString().trim();
       }
 
       mContent = null;