Author: almaw
Date: Thu Jan 25 14:20:35 2007
New Revision: 500019

URL: http://svn.apache.org/viewvc?view=rev&rev=500019
Log:
Move to using relative URLs.

Modified:
    
incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/protocol/http/WebApplication.java
    
incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/protocol/http/request/WebRequestCodingStrategy.java

Modified: 
incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/protocol/http/WebApplication.java
URL: 
http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/protocol/http/WebApplication.java?view=diff&rev=500019&r1=500018&r2=500019
==============================================================================
--- 
incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/protocol/http/WebApplication.java
 (original)
+++ 
incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/protocol/http/WebApplication.java
 Thu Jan 25 14:20:35 2007
@@ -181,7 +181,7 @@
 
        /**
         * Returns the full rootpath of this application. This is the
-        * ApplicationSettings.contextpath and the WicketFilter.rootpath 
concatted.
+        * ApplicationSettings.contextpath and the WicketFilter.filterPath 
concatted.
         * 
         * @return String the full rootpath.
         */
@@ -190,6 +190,16 @@
                HttpServletRequest httpServletRequest = 
((WebRequestCycle)RequestCycle.get())
                                .getWebRequest().getHttpServletRequest();
                return wicketFilter.getRootPath(httpServletRequest);
+       }
+
+       /**
+        * Returns the WicketFilter.filterpath path of this application.
+        * 
+        * @return String the full rootpath.
+        */
+       public String getFilterPath()
+       {
+               return wicketFilter.getFilterPath();
        }
 
        /**

Modified: 
incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/protocol/http/request/WebRequestCodingStrategy.java
URL: 
http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/protocol/http/request/WebRequestCodingStrategy.java?view=diff&rev=500019&r1=500018&r2=500019
==============================================================================
--- 
incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/protocol/http/request/WebRequestCodingStrategy.java
 (original)
+++ 
incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/protocol/http/request/WebRequestCodingStrategy.java
 Thu Jan 25 14:20:35 2007
@@ -52,6 +52,7 @@
 import 
wicket.request.target.component.listener.IListenerInterfaceRequestTarget;
 import wicket.request.target.resource.ISharedResourceRequestTarget;
 import wicket.util.string.AppendingStringBuffer;
+import wicket.util.string.PrependingStringBuffer;
 import wicket.util.string.Strings;
 
 /**
@@ -256,15 +257,20 @@
                
                if (url != null)
                {
+                       String rootPath = 
((WebApplication)Application.get()).getRootPath();
+                       String filterPath = 
((WebApplication)Application.get()).getFilterPath();
+                       
+                       // Strip off leading /
                        if (url.length() > 0 && url.charAt(0) == '/')
                        {
                                url = url.subSequence(1, url.length());
                        }
-
                        if (absolutePath)
                        {
-                               url = urlPrefix(requestCycle).toString() + url;
+                               url = rootPath + "/" + url;
+                               return 
requestCycle.getOriginalResponse().encodeURL(url);
                        }
+
                        String relativeUrl = 
requestCycle.getRequest().getRelativeURL();
                        String segments = "";
                        for (int i = 0; i < relativeUrl.length(); i++)
@@ -278,16 +284,29 @@
                                        segments += "../";
                                }
                        }
-                       if (segments.length() > 0)
-                       {
-                               url = segments + url;
+                       PrependingStringBuffer prepender = new 
PrependingStringBuffer();
+                       
+                       prepender.prepend(url.toString());
+                       if (url.length() > 0 && (url.charAt(0) == '?' || 
url.charAt(0) == ';'))
+                       {
+                               if (segments.length() == 0) {
+                                       if (filterPath.length() == 0) {
+                                               prepender.prepend("./");
+                                       }
+                                       else {
+                                               
+                                       }
+                               }
                        }
-                       else if (url.length() > 0 && (url.charAt(0) == '?' || 
url.charAt(0) == ';'))
+                       else if (filterPath.length() > 0)
                        {
-                               url = "./" + url;
+                               prepender.prepend('/');
+                       }
+                       prepender.prepend(filterPath);
+                       if (segments.length() > 0) {
+                               prepender.prepend(segments);
                        }
-                       url = requestCycle.getOriginalResponse().encodeURL(url);
-                       return url;
+                       return 
requestCycle.getOriginalResponse().encodeURL(prepender.toString());
                }
                
                // Just return null intead of throwing an exception. So that it 
can be
@@ -843,23 +862,6 @@
        protected String getRequestPath(Request request)
        {
                return request.getPath();
-       }
-
-       /**
-        * Gets prefix.
-        * 
-        * @param requestCycle
-        *            the request cycle
-        * 
-        * @return prefix
-        */
-       protected final CharSequence urlPrefix(final RequestCycle requestCycle)
-       {
-               if (urlPrefix == null)
-               {
-                       urlPrefix = 
((WebApplication)Application.get()).getRootPath();
-               }
-               return urlPrefix;
        }
        
        /**


Reply via email to