You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by mg...@apache.org on 2010/10/25 19:57:12 UTC
svn commit: r1027208 -
/wicket/trunk/wicket/src/main/java/org/apache/wicket/DefaultExceptionMapper.java
Author: mgrigorov
Date: Mon Oct 25 17:57:12 2010
New Revision: 1027208
URL: http://svn.apache.org/viewvc?rev=1027208&view=rev
Log:
Always use RedirectPolicy.NEVER_REDIRECT when an error occurs during request processing.
For non-Ajax requests this will preserve the original page's URL and for Ajax ones this will indicate the error so that their onFailure() is being called
Modified:
wicket/trunk/wicket/src/main/java/org/apache/wicket/DefaultExceptionMapper.java
Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/DefaultExceptionMapper.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/DefaultExceptionMapper.java?rev=1027208&r1=1027207&r2=1027208&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/DefaultExceptionMapper.java (original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/DefaultExceptionMapper.java Mon Oct 25 17:57:12 2010
@@ -26,7 +26,6 @@ import org.apache.wicket.request.handler
import org.apache.wicket.request.handler.IPageRequestHandler;
import org.apache.wicket.request.handler.PageProvider;
import org.apache.wicket.request.handler.RenderPageRequestHandler;
-import org.apache.wicket.request.http.WebRequest;
import org.apache.wicket.request.http.handler.ErrorCodeResponseHandler;
import org.apache.wicket.request.mapper.StalePageException;
import org.apache.wicket.settings.IExceptionSettings;
@@ -52,7 +51,8 @@ public class DefaultExceptionMapper impl
catch (RuntimeException e2)
{
// hmmm, we were already handling an exception! give up
- logger.error("unexpected exception when handling another exception: " + e.getMessage(), e);
+ logger.error("unexpected exception when handling another exception: " + e.getMessage(),
+ e);
return new ErrorCodeResponseHandler(500);
}
}
@@ -109,18 +109,15 @@ public class DefaultExceptionMapper impl
RequestCycle requestCycle = RequestCycle.get();
if (requestCycle == null)
- throw new IllegalStateException("there is no current request cycle attached to this thread");
+ throw new IllegalStateException(
+ "there is no current request cycle attached to this thread");
+ /*
+ * Use NEVER_REDIRECT policy to preserve the original page's URL for non-Ajax requests and
+ * to indicate the error for Ajax requests so that their onFailure() is being called
+ */
RenderPageRequestHandler.RedirectPolicy redirect = RenderPageRequestHandler.RedirectPolicy.NEVER_REDIRECT;
- // in case of ajax we must redirect to show the error page
- if (requestCycle.getRequest() instanceof WebRequest)
- {
- WebRequest webRequest = (WebRequest)requestCycle.getRequest();
-
- if(webRequest.isAjax())
- redirect = RenderPageRequestHandler.RedirectPolicy.ALWAYS_REDIRECT;
- }
return new RenderPageRequestHandler(pageProvider, redirect);
}
@@ -134,7 +131,7 @@ public class DefaultExceptionMapper impl
IRequestHandler handler = requestCycle.getActiveRequestHandler();
- if(handler == null)
+ if (handler == null)
handler = requestCycle.getRequestHandlerScheduledAfterCurrent();
if (handler instanceof IPageRequestHandler)