You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2009/06/09 20:06:32 UTC

svn commit: r783085 - /myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/MultipartRequestWrapper.java

Author: lu4242
Date: Tue Jun  9 18:06:32 2009
New Revision: 783085

URL: http://svn.apache.org/viewvc?rev=783085&view=rev
Log:
TOMAHAWK-1108 MultipartRequestWrapper doesn't handle request parameters correctly in JSF 1.2/JSP 2.1 (Thanks to Ben Smith)

Modified:
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/MultipartRequestWrapper.java

Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/MultipartRequestWrapper.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/MultipartRequestWrapper.java?rev=783085&r1=783084&r2=783085&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/MultipartRequestWrapper.java (original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/MultipartRequestWrapper.java Tue Jun  9 18:06:32 2009
@@ -23,6 +23,7 @@
 import java.util.Collections;
 import java.util.Enumeration;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -214,6 +215,10 @@
         }
 
         //Add the query string paramters
+        /* This code does only works if is true the assumption that query params
+         * are the same from start of the request. But it is possible
+         * use jsp:include and jsp:param to set query params after
+         * the request is parsed.
         for (Iterator it = request.getParameterMap().entrySet().iterator(); it.hasNext(); )
         {
             Map.Entry entry = (Map.Entry)it.next();
@@ -238,6 +243,7 @@
                         entry.getKey()+" cannot be handled.");
 
         }
+        */
     }
 
     private void addTextParameter(String name, String value){
@@ -257,28 +263,60 @@
     public Enumeration getParameterNames() {
         if( parametersMap == null ) parseRequest();
 
-        return Collections.enumeration( parametersMap.keySet() );
+        //return Collections.enumeration( parametersMap.keySet() );
+        HashSet mergedNames = new HashSet(parametersMap.keySet());
+        mergedNames.addAll(request.getParameterMap().keySet());
+        
+        return Collections.enumeration( mergedNames );
     }
 
     public String getParameter(String name) {
         if( parametersMap == null ) parseRequest();
 
         String[] values = (String[])parametersMap.get( name );
-        if( values == null )
+        //if( values == null )
+        //    return null;
+        //return values[0];
+        if (values != null)
+        {
+            return values[0];
+        }
+        else if (parametersMap.containsKey(name))
+        {
             return null;
-        return values[0];
+        }
+        else
+        {
+            return request.getParameter(name);
+        }
     }
 
     public String[] getParameterValues(String name) {
         if( parametersMap == null ) parseRequest();
 
-        return (String[])parametersMap.get( name );
+        //return (String[])parametersMap.get( name );
+        String[] values = (String[])parametersMap.get( name );
+        if (values != null)
+        {
+            return values;
+        }
+        else if (parametersMap.containsKey(name))
+        {
+            return null;
+        }
+        else
+        {
+            return request.getParameterValues(name);
+        }
     }
 
     public Map getParameterMap() {
         if( parametersMap == null ) parseRequest();
 
-        return parametersMap;
+        //return parametersMap;
+        HashMap mergedMap = new HashMap(parametersMap);
+        mergedMap.putAll(request.getParameterMap());        
+        return mergedMap;
     }
 
     // Hook for the x:inputFileUpload tag.