You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by jc...@apache.org on 2007/05/14 12:28:50 UTC
svn commit: r537771 - in
/incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http:
WebRequestCycle.java servlet/ServletWebRequest.java
Author: jcompagner
Date: Mon May 14 03:28:40 2007
New Revision: 537771
URL: http://svn.apache.org/viewvc?view=rev&rev=537771
Log:
relative urls for a bookmarkable request that will do a redirect to a wicket page fix.
Modified:
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/WebRequestCycle.java
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/servlet/ServletWebRequest.java
Modified: incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/WebRequestCycle.java
URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/WebRequestCycle.java?view=diff&rev=537771&r1=537770&r2=537771
==============================================================================
--- incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/WebRequestCycle.java (original)
+++ incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/WebRequestCycle.java Mon May 14 03:28:40 2007
@@ -26,6 +26,7 @@
import org.apache.wicket.Session;
import org.apache.wicket.markup.html.pages.BrowserInfoPage;
import org.apache.wicket.protocol.http.request.WebClientInfo;
+import org.apache.wicket.protocol.http.servlet.ServletWebRequest;
import org.apache.wicket.request.ClientInfo;
import org.apache.wicket.request.IRequestCycleProcessor;
import org.apache.wicket.settings.IRequestCycleSettings;
@@ -138,6 +139,13 @@
final WebResponse currentResponse = getWebResponse();
try
{
+ redirectUrl = page.urlFor(IRedirectListener.INTERFACE).toString();
+ if (getWebRequest() instanceof ServletWebRequest)
+ {
+ // Get the redirect url and set it in the ServletWebRequest
+ // so that it can be used for relative url calculation.
+ ((ServletWebRequest)getWebRequest()).setWicketRedirectUrl(redirectUrl.replaceAll("../", ""));
+ }
// create the redirect response.
final BufferedHttpServletResponse servletResponse = new BufferedHttpServletResponse(
currentResponse.getHttpServletResponse());
@@ -180,7 +188,6 @@
// here on.
servletResponse.close();
- redirectUrl = page.urlFor(IRedirectListener.INTERFACE).toString();
int index = redirectUrl.indexOf("?");
String sessionId = getWebRequest().getHttpServletRequest().getSession(true)
.getId();
Modified: incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/servlet/ServletWebRequest.java
URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/servlet/ServletWebRequest.java?view=diff&rev=537771&r1=537770&r2=537771
==============================================================================
--- incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/servlet/ServletWebRequest.java (original)
+++ incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/servlet/ServletWebRequest.java Mon May 14 03:28:40 2007
@@ -53,6 +53,8 @@
private String relativePathPrefixToWicketHandler;
private String relativePathPrefixToContextRoot;
private Map parameterMap;
+
+ private String wicketRedirectUrl;
/**
* Protected constructor.
@@ -213,7 +215,7 @@
// This gives us a context-relative path for RequestDispatcher.forward stuff, with a leading slash.
String forwardUrl = (String)httpRequest.getAttribute("javax.servlet.forward.servlet_path");
-
+
if (errorUrl != null)
{
// Strip off context path from front of URI.
@@ -243,6 +245,10 @@
// Strip off leading slash, if forwardUrl has any length.
relativeUrl = forwardUrl.substring(relativeUrl.length() > 0 ? 1 : 0);
}
+ else if (wicketRedirectUrl != null)
+ {
+ relativeUrl = wicketRedirectUrl;
+ }
if (depthRelativeToWicketHandler == -1)
{
@@ -394,5 +400,21 @@
+ httpServletRequest.getRequestURI() + ", servletPath = "
+ httpServletRequest.getServletPath() + ", pathTranslated = "
+ httpServletRequest.getPathTranslated() + "]";
+ }
+
+ /**
+ * Set the redirect url where wicket will redirect to for the next page
+ *
+ * @param wicketRedirectUrl
+ */
+ public void setWicketRedirectUrl(String wicketRedirectUrl)
+ {
+ this.wicketRedirectUrl = wicketRedirectUrl;
+ depthRelativeToWicketHandler = -1;
+ relativePathPrefixToContextRoot = null;
+ relativePathPrefixToWicketHandler = null;
+
+ getRequestParameters().setUrlDepth(getDepthRelativeToWicketHandler());
+
}
}
Re: svn commit: r537771 - in /incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http: WebRequestCycle.java servlet/ServletWebRequest.java
Posted by Johan Compagner <jc...@gmail.com>.
AlMaw and i already talked and discussed about this.
and this is currently the way that we did see.
we could do it maybe a bit better by only looking at the beginning
or have a special urlFor method that doesn't do the relative path
prepending..
I already described the problem a few days ago (i think late last week on
the dev list)
it was really a major problem for me because if i get a mount request
(bookmarkable url thats mounted)
then i always do a redirect to the page so /mout/mout2/mount3 would become
/?wicket:interface=xxxx
But in the redirect to buffer the page is rendered with the mount. So all
the urls that are in the resulting page
had ../../../ (the 3 mounts) and then ?wicket:interface or /resources
that is ofcourse really wrong because ../../../ is just the complete root
because the resulting url isn't the mount
but a wicket interface that is already a root. So all my pages especially
with ajax didn't work on the first request
(a refresh in the browser and it did work) and i have to do a redirect
because else if i do stuff with ajax on the page
and users then think i want a refrehs and they do that. Then it is just a
bookmarkable mount request again and they
loose there page with all the ajax changes
Maybe if matej finally makes its thingie that we keep the mount but do a
redirect but then with:
/mout/mout2/mount3[pageid:versionid]
then it works (so hybrid urls with mounts)
johan
That's sounds very hacky to me:
>
> redirectUrl.replaceAll("../", "")
>
> Can you describe the problem so that we try to provide a better
> fix (and hopefully AlMaw is listening to us ;-))
>
> Cheers,
> --
> Jean-Baptiste Quenot
> aka John Banana Qwerty
> http://caraldi.com/jbq/
>
Re: svn commit: r537771 - in /incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http:
WebRequestCycle.java servlet/ServletWebRequest.java
Posted by Al Maw <wi...@almaw.com>.
Jean-Baptiste Quenot wrote:
> That's sounds very hacky to me:
>
> redirectUrl.replaceAll("../", "")
>
> Can you describe the problem so that we try to provide a better
> fix (and hopefully AlMaw is listening to us ;-))
Yeah, I think it's hacky too, especially given the rest of this is now
fairly sane. Rest assured I'm looking into it.
Al
Re: svn commit: r537771 - in /incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http: WebRequestCycle.java servlet/ServletWebRequest.java
Posted by Jean-Baptiste Quenot <jb...@apache.org>.
* jcompagner@apache.org:
> Author: jcompagner
> Date: Mon May 14 03:28:40 2007
> New Revision: 537771
>
> URL: http://svn.apache.org/viewvc?view=rev&rev=537771
> Log:
> relative urls for a bookmarkable request that will do a redirect to a wicket page fix.
>
> Modified:
> incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/WebRequestCycle.java
> incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/servlet/ServletWebRequest.java
>
> Modified: incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/WebRequestCycle.java
>
> @@ -138,6 +139,13 @@
> final WebResponse currentResponse = getWebResponse();
> try
> {
> + redirectUrl = page.urlFor(IRedirectListener.INTERFACE).toString();
> + if (getWebRequest() instanceof ServletWebRequest)
> + {
> + // Get the redirect url and set it in the ServletWebRequest
> + // so that it can be used for relative url calculation.
> + ((ServletWebRequest)getWebRequest()).setWicketRedirectUrl(redirectUrl.replaceAll("../", ""));
> + }
That's sounds very hacky to me:
redirectUrl.replaceAll("../", "")
Can you describe the problem so that we try to provide a better
fix (and hopefully AlMaw is listening to us ;-))
Cheers,
--
Jean-Baptiste Quenot
aka John Banana Qwerty
http://caraldi.com/jbq/