You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by eh...@apache.org on 2007/08/28 08:06:35 UTC
svn commit: r570317 - in /wicket/trunk:
jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/pages/
jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/
jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/hellobrowser/
Author: ehillenius
Date: Mon Aug 27 23:06:34 2007
New Revision: 570317
URL: http://svn.apache.org/viewvc?rev=570317&view=rev
Log:
WICKET-896
Modified:
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/pages/BrowserInfoPage.java
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/WebRequestCycle.java
wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/hellobrowser/HelloBrowserApplication.java
Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/pages/BrowserInfoPage.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/pages/BrowserInfoPage.java?rev=570317&r1=570316&r2=570317&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/pages/BrowserInfoPage.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/pages/BrowserInfoPage.java Mon Aug 27 23:06:34 2007
@@ -21,7 +21,6 @@
import org.apache.wicket.AttributeModifier;
import org.apache.wicket.PageParameters;
import org.apache.wicket.RequestCycle;
-import org.apache.wicket.Response;
import org.apache.wicket.markup.html.WebComponent;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.WebPage;
@@ -31,6 +30,7 @@
import org.apache.wicket.protocol.http.WebSession;
import org.apache.wicket.protocol.http.request.WebClientInfo;
import org.apache.wicket.request.ClientInfo;
+import org.apache.wicket.request.target.basic.RedirectRequestTarget;
import org.apache.wicket.request.target.component.BookmarkablePageRequestTarget;
import org.apache.wicket.settings.IRequestCycleSettings;
import org.apache.wicket.util.string.Strings;
@@ -40,18 +40,15 @@
/**
* <p>
- * This page uses a form post right after the page has loaded in the browser,
- * using JavaScript or alternative means to detect and pass on settings to the
- * embedded form. The form submit method updates this session's
- * {@link org.apache.wicket.request.ClientInfo} object and then redirects to the
- * original location as was passed in as a URL argument in the constructor.
+ * This page uses a form post right after the page has loaded in the browser, using JavaScript or
+ * alternative means to detect and pass on settings to the embedded form. The form submit method
+ * updates this session's {@link org.apache.wicket.request.ClientInfo} object and then redirects to
+ * the original location as was passed in as a URL argument in the constructor.
* </p>
* <p>
- * This page is being used by the default implementation of
- * {@link WebRequestCycle#newClientInfo}, which in turn uses
- * {@link IRequestCycleSettings#getGatherExtendedBrowserInfo() a setting} to
- * determine whether this page should be redirected to (it does when it is
- * true).
+ * This page is being used by the default implementation of {@link WebRequestCycle#newClientInfo},
+ * which in turn uses {@link IRequestCycleSettings#getGatherExtendedBrowserInfo() a setting} to
+ * determine whether this page should be redirected to (it does when it is true).
* </p>
*
* @author Eelco Hillenius
@@ -67,10 +64,9 @@
private String continueTo;
/**
- * Bookmarkable constructor. This is not for normal framework client use. It
- * will be called whenever Javascript is not supported, and the browser info
- * page's meta refresh fires to this page. Prior to this, the other
- * constructor should already have been called.
+ * Bookmarkable constructor. This is not for normal framework client use. It will be called
+ * whenever Javascript is not supported, and the browser info page's meta refresh fires to this
+ * page. Prior to this, the other constructor should already have been called.
*
* @param parameters
* page parameters with the original url in it
@@ -106,8 +102,8 @@
}
/**
- * Constructor. The page will redirect to the given url after waiting for
- * the given number of seconds.
+ * Constructor. The page will redirect to the given url after waiting for the given number of
+ * seconds.
*
* @param continueTo
* the url to redirect to when the browser info is handled
@@ -165,29 +161,21 @@
protected final void continueToPrevious()
{
// continue to original distination
- RequestCycle requestCycle = getRequestCycle();
- // Since we are explicitly redirecting to a page already, we do not
- // want a second redirect to occur automatically
- requestCycle.setRedirect(false);
- // Redirect there
- Response response = requestCycle.getResponse();
- response.reset();
- response.redirect(requestCycle.getRequest().getRelativePathPrefixToWicketHandler()
- + continueTo);
+ RequestCycle.get().setRequestTarget(new RedirectRequestTarget(continueTo));
}
-
+
/**
- * Log a warning that for in order to use this page, you should really be
- * using {@link WebClientInfo}.
+ * Log a warning that for in order to use this page, you should really be using
+ * {@link WebClientInfo}.
*
* @param clientInfo
* the actual client info object
*/
void warnNotUsingWebClientInfo(ClientInfo clientInfo)
{
- log.warn("using " + getClass().getName() + " makes no sense if you are not using "
- + WebClientInfo.class.getName() + " (you are using "
- + clientInfo.getClass().getName() + " instead)");
+ log.warn("using " + getClass().getName() + " makes no sense if you are not using " +
+ WebClientInfo.class.getName() + " (you are using " +
+ clientInfo.getClass().getName() + " instead)");
}
/**
Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/WebRequestCycle.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/WebRequestCycle.java?rev=570317&r1=570316&r2=570317&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/WebRequestCycle.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/WebRequestCycle.java Mon Aug 27 23:06:34 2007
@@ -22,7 +22,7 @@
import org.apache.wicket.Page;
import org.apache.wicket.RequestCycle;
import org.apache.wicket.Response;
-import org.apache.wicket.RestartResponseAtInterceptPageException;
+import org.apache.wicket.RestartResponseException;
import org.apache.wicket.Session;
import org.apache.wicket.markup.html.pages.BrowserInfoPage;
import org.apache.wicket.protocol.http.request.WebClientInfo;
@@ -35,12 +35,11 @@
import org.slf4j.LoggerFactory;
/**
- * RequestCycle implementation for HTTP protocol. Holds the application,
- * session, request and response objects for a given HTTP request. Contains
- * methods (urlFor*) which yield a URL for bookmarkable pages as well as
- * non-bookmarkable component interfaces. The protected handleRender method is
- * the internal entrypoint which takes care of the details of rendering a
- * response to an HTTP request.
+ * RequestCycle implementation for HTTP protocol. Holds the application, session, request and
+ * response objects for a given HTTP request. Contains methods (urlFor*) which yield a URL for
+ * bookmarkable pages as well as non-bookmarkable component interfaces. The protected handleRender
+ * method is the internal entrypoint which takes care of the details of rendering a response to an
+ * HTTP request.
*
* @see RequestCycle
* @author Jonathan Locke
@@ -59,8 +58,8 @@
};
/**
- * Constructor which simply passes arguments to superclass for storage
- * there. This instance will be set as the current one for this thread.
+ * Constructor which simply passes arguments to superclass for storage there. This instance will
+ * be set as the current one for this thread.
*
* @param application
* The applicaiton
@@ -76,14 +75,13 @@
}
/**
- * By default returns the WebApplication's default request cycle processor.
- * Typically, you don't override this method but instead override
- * {@link WebApplication#getRequestCycleProcessor()}.
+ * By default returns the WebApplication's default request cycle processor. Typically, you don't
+ * override this method but instead override {@link WebApplication#getRequestCycleProcessor()}.
* <p>
- * <strong>if you decide to override this method to provide a custom
- * processor per request cycle, any mounts done via WebApplication will not
- * work and and {@link #onRuntimeException(Page, RuntimeException)} is not
- * called unless you deliberately put effort in it to make it work.</strong>
+ * <strong>if you decide to override this method to provide a custom processor per request
+ * cycle, any mounts done via WebApplication will not work and and
+ * {@link #onRuntimeException(Page, RuntimeException)} is not called unless you deliberately put
+ * effort in it to make it work.</strong>
* </p>
*
* @see org.apache.wicket.RequestCycle#getProcessor()
@@ -118,11 +116,10 @@
}
/**
- * Redirects browser to the given page. NOTE: Usually, you should never call
- * this method directly, but work with setResponsePage instead. This method
- * is part of Wicket's internal behavior and should only be used when you
- * want to circumvent the normal framework behavior and issue the redirect
- * directly.
+ * Redirects browser to the given page. NOTE: Usually, you should never call this method
+ * directly, but work with setResponsePage instead. This method is part of Wicket's internal
+ * behavior and should only be used when you want to circumvent the normal framework behavior
+ * and issue the redirect directly.
*
* @param page
* The page to redirect to
@@ -133,8 +130,8 @@
// Check if use serverside response for client side redirects
IRequestCycleSettings settings = application.getRequestCycleSettings();
- if ((settings.getRenderStrategy() == IRequestCycleSettings.REDIRECT_TO_BUFFER)
- && (application instanceof WebApplication))
+ if ((settings.getRenderStrategy() == IRequestCycleSettings.REDIRECT_TO_BUFFER) &&
+ (application instanceof WebApplication))
{
// remember the current response
final WebResponse currentResponse = getWebResponse();
@@ -144,7 +141,9 @@
{
// Get the redirect url and set it in the ServletWebRequest
// so that it can be used for relative url calculation.
- ((ServletWebRequest)getWebRequest()).setWicketRedirectUrl(Strings.replaceAll(page.urlFor(IRedirectListener.INTERFACE).toString(),"../","").toString());
+ ((ServletWebRequest)getWebRequest()).setWicketRedirectUrl(Strings.replaceAll(
+ page.urlFor(IRedirectListener.INTERFACE).toString(), "../", "")
+ .toString());
}
// create the redirect response.
final BufferedHttpServletResponse servletResponse = new BufferedHttpServletResponse(
@@ -192,14 +191,16 @@
{
// Get the redirect url and set it in the ServletWebRequest
// so that it can be used for relative url calculation.
- ((ServletWebRequest)getWebRequest()).setWicketRedirectUrl(null);
+ ((ServletWebRequest)getWebRequest()).setWicketRedirectUrl(null);
}
-
+
redirectUrl = page.urlFor(IRedirectListener.INTERFACE).toString();
- String stripped = Strings.replaceAll(redirectUrl,"../","").toString();
+ String stripped = Strings.replaceAll(redirectUrl, "../", "").toString();
int index = stripped.indexOf("?");
- String sessionId = getApplication().getSessionStore().getSessionId(request, true);
- ((WebApplication)application).addBufferedResponse(sessionId, stripped.substring(index + 1), servletResponse);
+ String sessionId = getApplication().getSessionStore().getSessionId(request,
+ true);
+ ((WebApplication)application).addBufferedResponse(sessionId, stripped
+ .substring(index + 1), servletResponse);
}
}
catch (RuntimeException ex)
@@ -258,7 +259,8 @@
// we haven't done the redirect yet; record that we will be
// doing that now and redirect
session.setMetaData(BROWSER_WAS_POLLED_KEY, Boolean.TRUE);
- throw new RestartResponseAtInterceptPageException(new BrowserInfoPage(getRequest().getRelativePathPrefixToContextRoot() + getRequest().getURL()));
+ String url = "/" + getRequest().getURL();
+ throw new RestartResponseException(new BrowserInfoPage(url));
}
// if we get here, the redirect already has been done; clear
// the meta data entry; we don't need it any longer is the client
Modified: wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/hellobrowser/HelloBrowserApplication.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/hellobrowser/HelloBrowserApplication.java?rev=570317&r1=570316&r2=570317&view=diff
==============================================================================
--- wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/hellobrowser/HelloBrowserApplication.java (original)
+++ wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/hellobrowser/HelloBrowserApplication.java Mon Aug 27 23:06:34 2007
@@ -17,6 +17,7 @@
package org.apache.wicket.examples.hellobrowser;
import org.apache.wicket.examples.WicketExampleApplication;
+import org.apache.wicket.util.lang.PackageName;
/**
* Application class for hello browser example.
@@ -46,5 +47,6 @@
protected void init()
{
getRequestCycleSettings().setGatherExtendedBrowserInfo(true);
+ mount("howdy", PackageName.forClass(HelloBrowserApplication.class));
}
}