incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r602147 - in /incubator/sling/trunk/microsling/microsling-core/src: main/java/org/apache/sling/microsling/slingservlets/ main/webapp/ test/java/org/apache/sling/microsling/integration/
Date Fri, 07 Dec 2007 16:42:46 GMT
Author: bdelacretaz
Date: Fri Dec  7 08:42:44 2007
New Revision: 602147

URL: http://svn.apache.org/viewvc?rev=602147&view=rev
Log:
SLING-126 - ujax_redirect=* now means 'redirect to created or modified node'

Modified:
    incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/slingservlets/MicrojaxPostServlet.java
    incubator/sling/trunk/microsling/microsling-core/src/main/webapp/content-creation-forms.html
    incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/PostRedirectTest.java

Modified: incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/slingservlets/MicrojaxPostServlet.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/slingservlets/MicrojaxPostServlet.java?rev=602147&r1=602146&r2=602147&view=diff
==============================================================================
--- incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/slingservlets/MicrojaxPostServlet.java
(original)
+++ incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/slingservlets/MicrojaxPostServlet.java
Fri Dec  7 08:42:44 2007
@@ -218,15 +218,18 @@
     /** compute redirect URL (SLING-126) */
     protected String getRedirectUrl(SlingHttpServletRequest request, String currentNodePath)
{
         
-        // redirect param has priority
+        // redirect param has priority (but see below, magic star)
         String result = request.getParameter(RP_REDIRECT_TO);
+        final boolean magicStar = "*".equals(result);
         
         if(result==null || result.trim().length()==0) {
             // try Referer
             result = request.getHeader("Referer");
         }
         
-        if(result==null || result.trim().length()==0) {
+        // redirect param = star means "redirect to current node", useful in browsers
+        // when you don't want to use the Referer
+        if(magicStar || result==null || result.trim().length()==0) {
             // use path of current node, with optional extension 
             final String redirectExtension = request.getParameter(RP_DISPLAY_EXTENSION);
             result = currentNodePath;

Modified: incubator/sling/trunk/microsling/microsling-core/src/main/webapp/content-creation-forms.html
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/microsling/microsling-core/src/main/webapp/content-creation-forms.html?rev=602147&r1=602146&r2=602147&view=diff
==============================================================================
--- incubator/sling/trunk/microsling/microsling-core/src/main/webapp/content-creation-forms.html
(original)
+++ incubator/sling/trunk/microsling/microsling-core/src/main/webapp/content-creation-forms.html
Fri Dec  7 08:42:44 2007
@@ -16,7 +16,10 @@
   
   <div>
     <form class="testbox" action="content/testing/*" method="POST">
+    
+      <!-- these parameters mean "redirect to created node with .html extension" -->
       <input type="hidden" name="ujax_displayExtension" value="html"/>
+      <input type="hidden" name="ujax_redirect" value="*"/>
       
       <h1>SlingPostServlet content creation form</h1>
       <p>

Modified: incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/PostRedirectTest.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/PostRedirectTest.java?rev=602147&r1=602146&r2=602147&view=diff
==============================================================================
--- incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/PostRedirectTest.java
(original)
+++ incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/PostRedirectTest.java
Fri Dec  7 08:42:44 2007
@@ -51,4 +51,16 @@
         final String location = testClient.createNode(postUrl, null, headers);
         assertEquals("With Referer, redirect must point to referer","http://referer/",location);
     }
+    
+    public void testMagicStarRedirect() throws IOException {
+        final Map<String,String> params = new HashMap<String,String>();
+        params.put("ujax_redirect","*");
+        final Map<String,String> headers = new HashMap<String,String>();
+        headers.put("Referer", "http://referer/");
+        final String location = testClient.createNode(postUrl, params, headers);
+        assertTrue(
+                "With magic star, redirect (" + location 
+                + ") must point to created node (path=" + postPath + ")",
+                location.contains(postPath));
+    }
 }



Mime
View raw message