]> source.dussan.org Git - gitblit.git/commitdiff
Bypass Wicket redirects after AJAX form submissions, they break Tomcat 36/136/1
authorJames Moger <james.moger@gitblit.com>
Tue, 30 Sep 2014 12:01:39 +0000 (08:01 -0400)
committerJames Moger <james.moger@gitblit.com>
Tue, 30 Sep 2014 12:01:39 +0000 (08:01 -0400)
src/main/java/com/gitblit/wicket/pages/BasePage.java
src/main/java/com/gitblit/wicket/pages/EditMilestonePage.java
src/main/java/com/gitblit/wicket/pages/EditTicketPage.java
src/main/java/com/gitblit/wicket/pages/NewMilestonePage.java
src/main/java/com/gitblit/wicket/pages/NewTicketPage.java
src/main/java/com/gitblit/wicket/pages/RootPage.java

index b454b7a8725493ff4ed6fadf8a463ce5c2b850cf..03d191846695802e016eeb607d85367044e52982 100644 (file)
@@ -45,6 +45,7 @@ import org.apache.wicket.markup.html.panel.FeedbackPanel;
 import org.apache.wicket.protocol.http.RequestUtils;\r
 import org.apache.wicket.protocol.http.WebResponse;\r
 import org.apache.wicket.protocol.http.servlet.ServletWebRequest;\r
+import org.apache.wicket.request.target.basic.RedirectRequestTarget;\r
 import org.apache.wicket.util.time.Duration;\r
 import org.apache.wicket.util.time.Time;\r
 import org.slf4j.Logger;\r
@@ -112,6 +113,15 @@ public abstract class BasePage extends SessionPage {
                return canonicalUrl;\r
        }\r
 \r
+       protected void manualRedirect(Class<? extends BasePage> pageClass) {\r
+               redirect(pageClass, null);\r
+       }\r
+\r
+       protected void redirect(Class<? extends BasePage> pageClass, PageParameters parameters) {\r
+               String absoluteUrl = getCanonicalUrl(pageClass, parameters);\r
+               getRequestCycle().setRequestTarget(new RedirectRequestTarget(absoluteUrl));\r
+       }\r
+\r
        protected String getLanguageCode() {\r
                return GitBlitWebSession.get().getLocale().getLanguage();\r
        }\r
@@ -495,4 +505,5 @@ public abstract class BasePage extends SessionPage {
                }\r
                return sb.toString();\r
        }\r
+\r
 }\r
index 4ed77d83a9e997bf79b3306e84062f6499620169..801631e8008337da15ff2ee58fb306dbbf67c2d9 100644 (file)
@@ -143,7 +143,7 @@ public class EditMilestonePage extends RepositoryPage {
                                }\r
 \r
                                if (success && app().tickets().updateMilestone(getRepositoryModel(), tm, createdBy)) {\r
-                                       setResponsePage(TicketsPage.class, WicketUtils.newOpenTicketsParameter(repositoryName));\r
+                                       redirect(TicketsPage.class, WicketUtils.newOpenTicketsParameter(repositoryName));\r
                                } else {\r
                                        // TODO error\r
                                }\r
index 074ffa607cb8b56576d785de42cb1e0a914dddc4..b55ce9c3a14bfc84c11a2c055a8f7cac97851bd6 100644 (file)
@@ -331,13 +331,13 @@ public class EditTicketPage extends RepositoryPage {
                                        if (ticket != null) {\r
                                                TicketNotifier notifier = app().tickets().createNotifier();\r
                                                notifier.sendMailing(ticket);\r
-                                               setResponsePage(TicketsPage.class, WicketUtils.newObjectParameter(getRepositoryModel().name, "" + ticket.number));\r
+                                               redirect(TicketsPage.class, WicketUtils.newObjectParameter(getRepositoryModel().name, "" + ticket.number));\r
                                        } else {\r
                                                // TODO error\r
                                        }\r
                                } else {\r
                                        // nothing to change?!\r
-                                       setResponsePage(TicketsPage.class, WicketUtils.newObjectParameter(getRepositoryModel().name, "" + ticket.number));\r
+                                       redirect(TicketsPage.class, WicketUtils.newObjectParameter(getRepositoryModel().name, "" + ticket.number));\r
                                }\r
                        }\r
                });\r
index cc331903e7c00b198992825a330e1f1c0332434c..24a43120049feb5c4371dd57b710d10df8e05a7e 100644 (file)
@@ -108,7 +108,7 @@ public class NewMilestonePage extends RepositoryPage {
                                if (milestone != null) {\r
                                        milestone.due = due;\r
                                        app().tickets().updateMilestone(getRepositoryModel(), milestone, createdBy);\r
-                                       throw new RestartResponseException(TicketsPage.class, WicketUtils.newOpenTicketsParameter(repositoryName));\r
+                                       redirect(TicketsPage.class, WicketUtils.newOpenTicketsParameter(repositoryName));\r
                                } else {\r
                                        // TODO error\r
                                }\r
index e6d9cb1e4c6b34d402832822bc6332319bce4847..f80a7d7eed87ee0d9d3cbc713290e0b97316dd78 100644 (file)
@@ -222,7 +222,8 @@ public class NewTicketPage extends RepositoryPage {
                                if (ticket != null) {\r
                                        TicketNotifier notifier = app().tickets().createNotifier();\r
                                        notifier.sendMailing(ticket);\r
-                                       setResponsePage(TicketsPage.class, WicketUtils.newObjectParameter(getRepositoryModel().name, "" + ticket.number));\r
+\r
+                                       redirect(TicketsPage.class, WicketUtils.newObjectParameter(getRepositoryModel().name, "" + ticket.number));\r
                                } else {\r
                                        // TODO error\r
                                }\r
index 6a933b76b6518b3c754627be14e3a266fe64893f..15e4304d65f431ebe4e88d0c56578668df6f36da 100644 (file)
@@ -280,12 +280,12 @@ public abstract class RootPage extends BasePage {
                                PageParameters params = getPageParameters();
                                if (params == null) {
                                        // redirect to this page
-                                       setResponsePage(getClass());
+                                       manualRedirect(getClass());
                                } else {
                                        // Strip username and password and redirect to this page
                                        params.remove("username");
                                        params.remove("password");
-                                       setResponsePage(getClass(), params);
+                                       redirect(getClass(), params);
                                }
                        }
                }