Author: ivaynberg
Date: Mon Jul 23 13:18:20 2007
New Revision: 558851

URL: http://svn.apache.org/viewvc?view=rev&rev=558851
Log:
WICKET-765 make all urls end with / so instead of /app/param1/value1?query it 
is now always /app/param1/value1/? just like it is in 1.2.6

Modified:
    
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/request/target/basic/URIRequestTargetUrlCodingStrategy.java
    
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/request/target/coding/AbstractRequestTargetUrlCodingStrategy.java
    
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/request/target/coding/IndexedParamUrlCodingStrategy.java
    
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/request/target/coding/MixedParamUrlCodingStrategy.java
    
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/request/target/coding/PackageRequestTargetUrlCodingStrategy.java
    
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/request/target/coding/QueryStringUrlCodingStrategy.java
    
incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/link/IndexedParamUrlCodingTest.java
    
incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/request/target/coding/MixedParamUrlCodingStrategyTest.java
    
incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/request/target/coding/QueryStringUrlCodingStrategyTest.java
    
incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/stateless/StatelessComponentPage_mount_result.html
    
incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/util/parse/metapattern/parsers/IndexedParamTest_ExpectedResult-1.html

Modified: 
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/request/target/basic/URIRequestTargetUrlCodingStrategy.java
URL: 
http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/request/target/basic/URIRequestTargetUrlCodingStrategy.java?view=diff&rev=558851&r1=558850&r2=558851
==============================================================================
--- 
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/request/target/basic/URIRequestTargetUrlCodingStrategy.java
 (original)
+++ 
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/request/target/basic/URIRequestTargetUrlCodingStrategy.java
 Mon Jul 23 13:18:20 2007
@@ -21,7 +21,6 @@
 import java.util.TreeMap;
 import java.util.Map.Entry;
 
-import javax.servlet.ServletRequest;
 import javax.servlet.http.HttpServletRequest;
 
 import org.apache.wicket.IRequestTarget;
@@ -143,6 +142,10 @@
                if (parameters.get(URI) != null)
                {
                        url.append("/").append(parameters.get(URI));
+               }
+               if (!url.endsWith("/"))
+               {
+                       url.append("/");
                }
 
                // Copied from QueryStringUrlCodingStrategy

Modified: 
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/request/target/coding/AbstractRequestTargetUrlCodingStrategy.java
URL: 
http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/request/target/coding/AbstractRequestTargetUrlCodingStrategy.java?view=diff&rev=558851&r1=558850&r2=558851
==============================================================================
--- 
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/request/target/coding/AbstractRequestTargetUrlCodingStrategy.java
 (original)
+++ 
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/request/target/coding/AbstractRequestTargetUrlCodingStrategy.java
 Mon Jul 23 13:18:20 2007
@@ -129,7 +129,11 @@
                String escapedValue = urlEncode(value);
                if (!Strings.isEmpty(escapedValue))
                {
-                       
url.append("/").append(key).append("/").append(escapedValue);
+                       if (!url.endsWith("/"))
+                       {
+                               url.append("/");
+                       }
+                       
url.append(key).append("/").append(escapedValue).append("/");
                }
        }
 
@@ -149,6 +153,11 @@
                if (urlFragment.startsWith("/"))
                {
                        urlFragment = urlFragment.substring(1);
+               }
+               // Hack off any trailing slash
+               if (urlFragment.length() > 0 && urlFragment.endsWith("/"))
+               {
+                       urlFragment = urlFragment.substring(0, 
urlFragment.length() - 1);
                }
 
                if (urlFragment.length() == 0)

Modified: 
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/request/target/coding/IndexedParamUrlCodingStrategy.java
URL: 
http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/request/target/coding/IndexedParamUrlCodingStrategy.java?view=diff&rev=558851&r1=558850&r2=558851
==============================================================================
--- 
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/request/target/coding/IndexedParamUrlCodingStrategy.java
 (original)
+++ 
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/request/target/coding/IndexedParamUrlCodingStrategy.java
 Mon Jul 23 13:18:20 2007
@@ -76,7 +76,11 @@
                while (parameters.containsKey(String.valueOf(i)))
                {
                        String value = 
(String)parameters.get(String.valueOf(i));
-                       url.append("/").append(urlEncode(value));
+                       if (!url.endsWith("/"))
+                       {
+                               url.append("/");
+                       }
+                       url.append(urlEncode(value)).append("/");
                        i++;
                }
 
@@ -85,8 +89,12 @@
                {
                        i++;
                        pageMap = 
WebRequestCodingStrategy.encodePageMapName(pageMap);
-                       
url.append("/").append(WebRequestCodingStrategy.PAGEMAP).append("/").append(
-                                       urlEncode(pageMap));
+                       if (!url.endsWith("/"))
+                       {
+                               url.append("/");
+                       }
+                       
url.append(WebRequestCodingStrategy.PAGEMAP).append("/").append(urlEncode(pageMap))
+                                       .append("/");
                }
 
                if (i != parameters.size())
@@ -107,6 +115,10 @@
                if (urlFragment.startsWith("/"))
                {
                        urlFragment = urlFragment.substring(1);
+               }
+               if (urlFragment.length() > 0 && urlFragment.endsWith("/"))
+               {
+                       urlFragment = urlFragment.substring(0, 
urlFragment.length() - 1);
                }
 
                String[] parts = urlFragment.split("/");

Modified: 
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/request/target/coding/MixedParamUrlCodingStrategy.java
URL: 
http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/request/target/coding/MixedParamUrlCodingStrategy.java?view=diff&rev=558851&r1=558850&r2=558851
==============================================================================
--- 
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/request/target/coding/MixedParamUrlCodingStrategy.java
 (original)
+++ 
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/request/target/coding/MixedParamUrlCodingStrategy.java
 Mon Jul 23 13:18:20 2007
@@ -110,6 +110,11 @@
        /** [EMAIL PROTECTED] */
        protected void appendParameters(AppendingStringBuffer url, Map 
parameters)
        {
+               if (!url.endsWith("/"))
+               {
+                       url.append("/");
+               }
+
                Set parameterNamesToAdd = new HashSet(parameters.keySet());
                // Find index of last specified parameter
                boolean foundParameter = false;
@@ -129,7 +134,7 @@
                                {
                                        value = "";
                                }
-                               url.append("/").append(urlEncode(value));
+                               url.append(urlEncode(value)).append("/");
                                parameterNamesToAdd.remove(parameterName);
                        }
                }
@@ -142,7 +147,7 @@
                        {
                                iterator = new 
TreeSet(parameterNamesToAdd).iterator();
                        }
-                       else 
+                       else
                        {
                                iterator = parameterNamesToAdd.iterator();
                        }

Modified: 
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/request/target/coding/PackageRequestTargetUrlCodingStrategy.java
URL: 
http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/request/target/coding/PackageRequestTargetUrlCodingStrategy.java?view=diff&rev=558851&r1=558850&r2=558851
==============================================================================
--- 
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/request/target/coding/PackageRequestTargetUrlCodingStrategy.java
 (original)
+++ 
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/request/target/coding/PackageRequestTargetUrlCodingStrategy.java
 Mon Jul 23 13:18:20 2007
@@ -139,7 +139,7 @@
                AppendingStringBuffer url = new AppendingStringBuffer(40);
                url.append(getMountPath());
                IBookmarkablePageRequestTarget target = 
(IBookmarkablePageRequestTarget)requestTarget;
-               
url.append("/").append(Classes.simpleName(target.getPageClass()));
+               
url.append("/").append(Classes.simpleName(target.getPageClass())).append("/");
 
                PageParameters pageParameters = target.getPageParameters();
                if (target.getPageMapName() != null)

Modified: 
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/request/target/coding/QueryStringUrlCodingStrategy.java
URL: 
http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/request/target/coding/QueryStringUrlCodingStrategy.java?view=diff&rev=558851&r1=558850&r2=558851
==============================================================================
--- 
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/request/target/coding/QueryStringUrlCodingStrategy.java
 (original)
+++ 
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/request/target/coding/QueryStringUrlCodingStrategy.java
 Mon Jul 23 13:18:20 2007
@@ -74,8 +74,8 @@
  * </ul>
  * <p>
  * Regardless of which coding strategy is chosen for the mount,
- * [EMAIL PROTECTED] org.apache.wicket.markup.html.link.BookmarkablePageLink 
BookmarkablePageLink} can
- * be used to insert a bookmarkable link to the request target.
+ * [EMAIL PROTECTED] org.apache.wicket.markup.html.link.BookmarkablePageLink 
BookmarkablePageLink}
+ * can be used to insert a bookmarkable link to the request target.
  * <p>
  * This example demonstrates how to mount a path with
  * <code>QueryStringRequestTargetUrlCodingStrategy</code> within the
@@ -120,7 +120,10 @@
         */
        protected void appendParameters(AppendingStringBuffer url, Map 
parameters)
        {
-
+               if (!url.endsWith("/"))
+               {
+                       url.append("/");
+               }
                if (parameters != null && parameters.size() > 0)
                {
                        final Iterator entries;
@@ -130,7 +133,7 @@
                        }
                        else
                        {
-                               entries = parameters.entrySet().iterator();     
                        
+                               entries = parameters.entrySet().iterator();
                        }
                        WebRequestEncoder encoder = new WebRequestEncoder(url);
                        while (entries.hasNext())
@@ -144,21 +147,24 @@
                        }
                }
        }
-       
+
        public IRequestTarget decode(RequestParameters requestParameters)
        {
                String pageMapName = requestParameters.getPageMapName();
                final PageParameters parameters = new 
PageParameters(requestParameters.getParameters());
-               
-               // This might be a request to a stateless page, so check for an 
interface name.
-               if (requestParameters.getInterfaceName() != null) {
+
+               // This might be a request to a stateless page, so check for an
+               // interface name.
+               if (requestParameters.getInterfaceName() != null)
+               {
                        return new 
BookmarkableListenerInterfaceRequestTarget(pageMapName,
-                                       (Class)bookmarkablePageClassRef.get(), 
parameters, requestParameters.getComponentPath(),
-                                       requestParameters.getInterfaceName());
+                                       (Class)bookmarkablePageClassRef.get(), 
parameters, requestParameters
+                                                       .getComponentPath(), 
requestParameters.getInterfaceName());
                }
                else
                {
-                       return new BookmarkablePageRequestTarget(pageMapName, 
(Class)bookmarkablePageClassRef.get(), parameters);
+                       return new BookmarkablePageRequestTarget(pageMapName, 
(Class)bookmarkablePageClassRef
+                                       .get(), parameters);
                }
        }
 

Modified: 
incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/link/IndexedParamUrlCodingTest.java
URL: 
http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/link/IndexedParamUrlCodingTest.java?view=diff&rev=558851&r1=558850&r2=558851
==============================================================================
--- 
incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/link/IndexedParamUrlCodingTest.java
 (original)
+++ 
incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/link/IndexedParamUrlCodingTest.java
 Mon Jul 23 13:18:20 2007
@@ -68,8 +68,8 @@
                String url2 = cycle.urlFor(
                                new BookmarkablePageRequestTarget("mypagemap", 
BookmarkableHomePageLinksPage.class,
                                                parameters)).toString();
-               assertEquals("test1/Integer0/Integer1/a%3Ab", url1);
-               
assertEquals("test2/Integer0/Integer1/a%3Ab/wicket:pageMapName/mypagemap", 
url2);
+               assertEquals("test1/Integer0/Integer1/a%3Ab/", url1);
+               
assertEquals("test2/Integer0/Integer1/a%3Ab/wicket:pageMapName/mypagemap/", 
url2);
 
                tester.setupRequestAndResponse();
                
tester.getServletRequest().setURL("/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication/"
 + url1);

Modified: 
incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/request/target/coding/MixedParamUrlCodingStrategyTest.java
URL: 
http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/request/target/coding/MixedParamUrlCodingStrategyTest.java?view=diff&rev=558851&r1=558850&r2=558851
==============================================================================
--- 
incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/request/target/coding/MixedParamUrlCodingStrategyTest.java
 (original)
+++ 
incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/request/target/coding/MixedParamUrlCodingStrategyTest.java
 Mon Jul 23 13:18:20 2007
@@ -64,7 +64,7 @@
                AppendingStringBuffer url = new AppendingStringBuffer(40);
                npucs.appendParameters(url, parameters);
                String urlStr = url.toString();
-               assertTrue("/1?d=4&e=5".equals(urlStr) || 
"/1?e=5&d=4".equals(urlStr));
+               assertTrue("/1/?d=4&e=5".equals(urlStr) || 
"/1/?e=5&d=4".equals(urlStr));
        }
 
        /**
@@ -87,7 +87,7 @@
                AppendingStringBuffer url = new AppendingStringBuffer(40);
                npucs.appendParameters(url, parameters);
                String urlStr = url.toString();
-               assertTrue("/1/2/3?d=4&e=5".equals(urlStr) || 
"/1/2/3?e=5&d=4".equals(urlStr));
+               assertTrue("/1/2/3/?d=4&e=5".equals(urlStr) || 
"/1/2/3/?e=5&d=4".equals(urlStr));
        }
 
        /**
@@ -153,7 +153,7 @@
 
                AppendingStringBuffer url = new AppendingStringBuffer(40);
                npucs.appendParameters(url, parameters);
-               assertEquals("/1/2/3", url.toString());
+               assertEquals("/1/2/3/", url.toString());
        }
 
        /**
@@ -175,7 +175,7 @@
                AppendingStringBuffer url = new AppendingStringBuffer(40);
                npucs.appendParameters(url, parameters);
                String urlStr = url.toString();
-               assertTrue("/1//3?d=4&e=5".equals(urlStr) || 
"/1//3?e=5&d=4".equals(urlStr));
+               assertTrue("/1//3/?d=4&e=5".equals(urlStr) || 
"/1//3/?e=5&d=4".equals(urlStr));
        }
 
        /**

Modified: 
incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/request/target/coding/QueryStringUrlCodingStrategyTest.java
URL: 
http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/request/target/coding/QueryStringUrlCodingStrategyTest.java?view=diff&rev=558851&r1=558850&r2=558851
==============================================================================
--- 
incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/request/target/coding/QueryStringUrlCodingStrategyTest.java
 (original)
+++ 
incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/request/target/coding/QueryStringUrlCodingStrategyTest.java
 Mon Jul 23 13:18:20 2007
@@ -45,6 +45,6 @@
                IRequestTarget rt = new 
BookmarkablePageRequestTarget(TestPage.class, params);
                String path = ucs.encode(rt).toString();
                log.debug(path);
-               assertEquals("mount/point?a=1&a=2&b=1", path);
+               assertEquals("mount/point/?a=1&a=2&b=1", path);
        }
 }

Modified: 
incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/stateless/StatelessComponentPage_mount_result.html
URL: 
http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/stateless/StatelessComponentPage_mount_result.html?view=diff&rev=558851&r1=558850&r2=558851
==============================================================================
--- 
incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/stateless/StatelessComponentPage_mount_result.html
 (original)
+++ 
incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/stateless/StatelessComponentPage_mount_result.html
 Mon Jul 23 13:18:20 2007
@@ -1,5 +1,5 @@
 <html>
 <body>
-<a href="stateless/wicket:interface/%3A0%3Alink%3A%3AILinkListener%3A%3A" 
wicket:id="link">test</a>
+<a href="stateless/wicket:interface/%3A0%3Alink%3A%3AILinkListener%3A%3A/" 
wicket:id="link">test</a>
 </body>
 </html>

Modified: 
incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/util/parse/metapattern/parsers/IndexedParamTest_ExpectedResult-1.html
URL: 
http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/util/parse/metapattern/parsers/IndexedParamTest_ExpectedResult-1.html?view=diff&rev=558851&r1=558850&r2=558851
==============================================================================
--- 
incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/util/parse/metapattern/parsers/IndexedParamTest_ExpectedResult-1.html
 (original)
+++ 
incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/util/parse/metapattern/parsers/IndexedParamTest_ExpectedResult-1.html
 Mon Jul 23 13:18:20 2007
@@ -1,6 +1,6 @@
 <html>
 <body>
     Link:
-    <wicket:link><a href="page2/abc">Page 1</a></wicket:link>
+    <wicket:link><a href="page2/abc/">Page 1</a></wicket:link>
 </body>
 </html>


Reply via email to