You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by sv...@apache.org on 2014/04/01 15:20:41 UTC

git commit: WICKET-5549 redirect to page if ajax request is not sent by wicket-ajax.js

Repository: wicket
Updated Branches:
  refs/heads/wicket-6.x 9f9361ec7 -> d3b492a91


WICKET-5549 redirect to page if ajax request is not sent by
wicket-ajax.js

Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/d3b492a9
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/d3b492a9
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/d3b492a9

Branch: refs/heads/wicket-6.x
Commit: d3b492a917ddb36ed88782b5c598c5bc51a268c0
Parents: 9f9361e
Author: svenmeier <sv...@meiers.net>
Authored: Tue Apr 1 15:11:09 2014 +0200
Committer: svenmeier <sv...@meiers.net>
Committed: Tue Apr 1 15:11:09 2014 +0200

----------------------------------------------------------------------
 .../apache/wicket/ajax/AjaxRequestHandler.java  | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/d3b492a9/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxRequestHandler.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxRequestHandler.java b/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxRequestHandler.java
index 3c6faf1..e74f61e 100644
--- a/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxRequestHandler.java
+++ b/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxRequestHandler.java
@@ -325,7 +325,7 @@ public class AjaxRequestHandler implements AjaxRequestTarget
 		final RequestCycle rc = (RequestCycle)requestCycle;
 		final WebResponse response = (WebResponse)requestCycle.getResponse();
 
-		if (responseObject.containsPage())
+		if (shouldRedirectToPage(requestCycle))
 		{
 			// the page itself has been added to the request target, we simply issue a redirect
 			// back to the page
@@ -361,6 +361,24 @@ public class AjaxRequestHandler implements AjaxRequestTarget
 		response.write(filteredResponse);
 	}
 
+	private boolean shouldRedirectToPage(IRequestCycle requestCycle)
+	{
+		if (responseObject.containsPage())
+		{
+			return true;
+		}
+
+		if (((WebRequest)requestCycle.getRequest()).isAjax() == false)
+		{
+			// the request was not sent by wicket-ajax.js - this can happen when an Ajax request was
+			// intercepted with #redirectToInterceptPage() and then the original request is re-sent
+			// by the browser on a subsequent #continueToOriginalDestination()
+			return true;
+		}
+
+		return false;
+	}
+
 	/**
 	 * Runs the configured {@link IResponseFilter}s over the constructed Ajax response
 	 *