You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by jb...@apache.org on 2007/03/09 22:10:39 UTC
svn commit: r516551 - in /incubator/wicket/branches/wicket-1.x/wicket/src:
main/java/wicket/protocol/http/WebResponse.java
test/java/wicket/protocol/http/WebResponseExceptionsTest.java
Author: jbq
Date: Fri Mar 9 13:10:38 2007
New Revision: 516551
URL: http://svn.apache.org/viewvc?view=rev&rev=516551
Log:
Fix WICKET-313 Use standard exception handling in AjaxRequestTarget
Reset the HTTP response status code to 200, otherwise wicket-ajax.js does not
process the Ajax-Location header. Also added unit test for this usecase.
Modified:
incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/protocol/http/WebResponse.java
incubator/wicket/branches/wicket-1.x/wicket/src/test/java/wicket/protocol/http/WebResponseExceptionsTest.java
Modified: incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/protocol/http/WebResponse.java
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/protocol/http/WebResponse.java?view=diff&rev=516551&r1=516550&r2=516551
==============================================================================
--- incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/protocol/http/WebResponse.java (original)
+++ incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/protocol/http/WebResponse.java Fri Mar 9 13:10:38 2007
@@ -192,6 +192,10 @@
if (isAjax())
{
+ // Reset the HTTP response status code to 200, otherwise
+ // wicket-ajax.js does not process the Ajax-Location
+ // header
+ httpServletResponse.setStatus(HttpServletResponse.SC_OK);
httpServletResponse.addHeader("Ajax-Location", url);
// safari chokes on empty response. but perhaps this is
Modified: incubator/wicket/branches/wicket-1.x/wicket/src/test/java/wicket/protocol/http/WebResponseExceptionsTest.java
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/wicket/src/test/java/wicket/protocol/http/WebResponseExceptionsTest.java?view=diff&rev=516551&r1=516550&r2=516551
==============================================================================
--- incubator/wicket/branches/wicket-1.x/wicket/src/test/java/wicket/protocol/http/WebResponseExceptionsTest.java (original)
+++ incubator/wicket/branches/wicket-1.x/wicket/src/test/java/wicket/protocol/http/WebResponseExceptionsTest.java Fri Mar 9 13:10:38 2007
@@ -22,6 +22,8 @@
import wicket.WicketTestCase;
import wicket.ajax.AjaxEventBehavior;
import wicket.ajax.markup.html.AjaxLink;
+import wicket.settings.IExceptionSettings;
+import wicket.settings.IRequestCycleSettings;
import wicket.util.tester.WicketTester;
/**
@@ -33,7 +35,7 @@
{
private static final Log log = LogFactory.getLog(WebResponseExceptionsTest.class);
- public void testErrorPage()
+ public void testInternalErrorPage()
{
tester.startPage(TestErrorPage.class);
AjaxLink link = (AjaxLink)tester.getComponentFromLastRenderedPage("link");
@@ -59,6 +61,17 @@
assertAjaxLocation(tester);
}
+ public void testBufferedExceptionErrorPage() {
+ tester.getApplication().getRequestCycleSettings().setRenderStrategy(IRequestCycleSettings.REDIRECT_TO_BUFFER);
+ tester.getApplication().getExceptionSettings().setUnexpectedExceptionDisplay(IExceptionSettings.SHOW_EXCEPTION_PAGE);
+ testInternalErrorPage();
+ }
+
+ public void testExceptionErrorPage() {
+ tester.getApplication().getExceptionSettings().setUnexpectedExceptionDisplay(IExceptionSettings.SHOW_EXCEPTION_PAGE);
+ testInternalErrorPage();
+ }
+
public void testExpirePage()
{
tester.startPage(TestExpirePage.class);
@@ -97,5 +110,7 @@
String ajaxLocation = ((MockHttpServletResponse)tester.getWicketResponse().getHttpServletResponse()).getHeader("Ajax-Location");
log.debug(ajaxLocation);
assertNotNull("Ajax-Location header should be present when using Ajax", ajaxLocation);
+ int statusCode = ((MockHttpServletResponse)tester.getWicketResponse().getHttpServletResponse()).getStatus();
+ assertEquals(200, statusCode);
}
}