You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by re...@apache.org on 2010/10/14 09:45:29 UTC

svn commit: r1022400 - in /cocoon/cocoon3/trunk: cocoon-docs/src/changes/changes.xml cocoon-servlet/src/main/java/org/apache/cocoon/servlet/util/ObjectModelProvider.java

Author: reinhard
Date: Thu Oct 14 07:45:29 2010
New Revision: 1022400

URL: http://svn.apache.org/viewvc?rev=1022400&view=rev
Log:
<action dev="reinhard" type="add">
  [cocoon-servlet] Add the method 'emulatedMethod()' to the request object. It supports the RubyOnRails
  way of sending an alternative HTTP method to the server in cases where only GET and POST work reliably.
  The method returns either the value of the request parameter '_method' or if not available, the actually
  used HTTP method. In future versions of Cocoon this behavior might become the default behavior of Cocoon.
</action>	

Modified:
    cocoon/cocoon3/trunk/cocoon-docs/src/changes/changes.xml
    cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/util/ObjectModelProvider.java

Modified: cocoon/cocoon3/trunk/cocoon-docs/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-docs/src/changes/changes.xml?rev=1022400&r1=1022399&r2=1022400&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-docs/src/changes/changes.xml (original)
+++ cocoon/cocoon3/trunk/cocoon-docs/src/changes/changes.xml Thu Oct 14 07:45:29 2010
@@ -64,6 +64,13 @@
         and the pipeline that embeds the controllers becomes cacheable.
       </action>
 
+      <action dev="reinhard" type="add">
+        [cocoon-servlet] Add the method 'emulatedMethod()' to the request object. It supports the RubyOnRails
+        way of sending an alternative HTTP method to the server in cases where only GET and POST work reliably.
+        The method returns either the value of the request parameter '_method' or if not available, the actually
+        used HTTP method. In future versions of Cocoon this behavior might become the default behavior of Cocoon.
+	  </action>
+
       <action dev="reinhard" type="update">
         [all] Upgrade all modules that have a dependency on Spring version 3.0.1.RELEASE
       </action>

Modified: cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/util/ObjectModelProvider.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/util/ObjectModelProvider.java?rev=1022400&r1=1022399&r2=1022400&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/util/ObjectModelProvider.java (original)
+++ cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/util/ObjectModelProvider.java Thu Oct 14 07:45:29 2010
@@ -49,7 +49,8 @@ public class ObjectModelProvider {
     }
 
     /**
-     * A wrapper that can be used by expression languages to provide shortcuts to the request parameters.
+     * A wrapper that can be used by expression languages to provide shortcuts to the request parameters and provides
+     * Cocoon specific information about the request.
      */
     public static class ObjectModelRequest extends HttpServletRequestWrapper {
 
@@ -61,6 +62,16 @@ public class ObjectModelProvider {
             return this.getParameter(key);
         }
 
+        public String getEmulatedMethod() {
+            String alternativeMethod = this.getParameter("_method");
+
+            if (alternativeMethod != null && !alternativeMethod.equals("")) {
+                return alternativeMethod.toUpperCase();
+            }
+
+            return this.getMethod();
+        }
+
         public boolean isSsf() {
             if(this.getRequest() instanceof ServletServiceRequest) {
                 return true;