im attaching a patch that implements [7]. there are no api breaks but the behavior is a bit different when it comes to errors obviously. could you guys please review and test. should we put this into 1.2.2 or save for 1.3?

-Igor

Index: src/java/wicket/request/compound/DefaultExceptionResponseStrategy.java
===================================================================
--- src/java/wicket/request/compound/DefaultExceptionResponseStrategy.java      
(revision 6950)
+++ src/java/wicket/request/compound/DefaultExceptionResponseStrategy.java      
(working copy)
@@ -18,16 +18,14 @@
 package wicket.request.compound;
 
 import wicket.Application;
-import wicket.IPageFactory;
-import wicket.IRequestTarget;
 import wicket.Page;
 import wicket.RequestCycle;
 import wicket.RestartResponseAtInterceptPageException;
+import wicket.RestartResponseException;
 import wicket.Session;
 import wicket.WicketRuntimeException;
 import wicket.authorization.AuthorizationException;
 import wicket.markup.html.pages.ExceptionErrorPage;
-import wicket.request.target.component.IPageRequestTarget;
 import wicket.settings.IExceptionSettings;
 
 /**
@@ -67,41 +65,39 @@
                if (override != null)
                {
                        requestCycle.setResponsePage(override);
+                       requestCycle.setRedirect(true);
                }
-               else if(e instanceof AuthorizationException)
+               else if (e instanceof AuthorizationException)
                {
-                       // are authorization exceptions always thrown before 
the real render?
-                       // else we need to make a page (see below) or set it 
hard to a redirect.
-                       Class accessDeniedPageClass = 
application.getApplicationSettings().getAccessDeniedPage();
-
+                       // are authorization exceptions always thrown before 
the real
+                       // render?
+                       // else we need to make a page (see below) or set it 
hard to a
+                       // redirect.
+                       Class accessDeniedPageClass = 
application.getApplicationSettings()
+                                       .getAccessDeniedPage();
                        throw new 
RestartResponseAtInterceptPageException(accessDeniedPageClass);
                }
                else if (settings.getUnexpectedExceptionDisplay() != 
IExceptionSettings.SHOW_NO_EXCEPTION_PAGE)
                {
-                       Class internalErrorPageClass = 
application.getApplicationSettings().getInternalErrorPage();
+                       // we do not want to redirect - we want to inline the 
error output
+                       // and preserve the url so when the refresh button is 
pressed we
+                       // rerun the code that caused the error
+                       requestCycle.setRedirect(false);
+
+                       // figure out which error page to show
+                       Class internalErrorPageClass = 
application.getApplicationSettings()
+                                       .getInternalErrorPage();
                        Class responseClass = responsePage != null ? 
responsePage.getClass() : null;
 
                        if (responseClass != internalErrorPageClass
                                        && 
settings.getUnexpectedExceptionDisplay() == 
IExceptionSettings.SHOW_INTERNAL_ERROR_PAGE)
                        {
-                               // Show internal error page
-                               final IPageFactory pageFactory;
-                               IRequestTarget requestTarget = 
requestCycle.getRequestTarget();
-                               if (requestTarget instanceof IPageRequestTarget)
-                               {
-                                       pageFactory = 
session.getPageFactory(((IPageRequestTarget)requestTarget)
-                                                       .getPage());
-                               }
-                               else
-                               {
-                                       pageFactory = session.getPageFactory();
-                               }
-                               
requestCycle.setResponsePage(pageFactory.newPage(internalErrorPageClass));
+                               throw new 
RestartResponseException(internalErrorPageClass);
                        }
                        else if (responseClass != ExceptionErrorPage.class)
                        {
                                // Show full details
-                               requestCycle.setResponsePage(new 
ExceptionErrorPage(e, responsePage));
+                               throw new RestartResponseException(new 
ExceptionErrorPage(e, responsePage));
                        }
                        else
                        {
@@ -110,17 +106,6 @@
                                                + internalErrorPageClass, e);
                        }
                }
-
-               // We generally want to redirect the response because we
-               // were in the middle of rendering and the page may end up
-               // looking like spaghetti otherwise. If responsePage == null,
-               // than the Page constructor failed and we don't need to
-               // redirect and this allows to reload the page when the
-               // bug has been fixed.
-               if (responsePage != null)
-               {
-                       requestCycle.setRedirect(true);
-               }
        }
 
        /**
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Wicket-develop mailing list
Wicket-develop@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-develop

Reply via email to