summaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authorJames Moger <james.moger@gitblit.com>2014-09-30 08:01:39 -0400
committerJames Moger <james.moger@gitblit.com>2014-09-30 08:01:39 -0400
commit2598bf3ff526f46259244d7c5f60dcc2241f3020 (patch)
tree238d883d220db08ee21c9c5cf77aca9ceb851ed1 /src/main/java
parent6fce727aca709a9940de0f2eac419b4791c3bf9a (diff)
downloadgitblit-2598bf3ff526f46259244d7c5f60dcc2241f3020.tar.gz
gitblit-2598bf3ff526f46259244d7c5f60dcc2241f3020.zip
Bypass Wicket redirects after AJAX form submissions, they break Tomcat
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/com/gitblit/wicket/pages/BasePage.java11
-rw-r--r--src/main/java/com/gitblit/wicket/pages/EditMilestonePage.java2
-rw-r--r--src/main/java/com/gitblit/wicket/pages/EditTicketPage.java4
-rw-r--r--src/main/java/com/gitblit/wicket/pages/NewMilestonePage.java2
-rw-r--r--src/main/java/com/gitblit/wicket/pages/NewTicketPage.java3
-rw-r--r--src/main/java/com/gitblit/wicket/pages/RootPage.java4
6 files changed, 19 insertions, 7 deletions
diff --git a/src/main/java/com/gitblit/wicket/pages/BasePage.java b/src/main/java/com/gitblit/wicket/pages/BasePage.java
index b454b7a8..03d19184 100644
--- a/src/main/java/com/gitblit/wicket/pages/BasePage.java
+++ b/src/main/java/com/gitblit/wicket/pages/BasePage.java
@@ -45,6 +45,7 @@ import org.apache.wicket.markup.html.panel.FeedbackPanel;
import org.apache.wicket.protocol.http.RequestUtils;
import org.apache.wicket.protocol.http.WebResponse;
import org.apache.wicket.protocol.http.servlet.ServletWebRequest;
+import org.apache.wicket.request.target.basic.RedirectRequestTarget;
import org.apache.wicket.util.time.Duration;
import org.apache.wicket.util.time.Time;
import org.slf4j.Logger;
@@ -112,6 +113,15 @@ public abstract class BasePage extends SessionPage {
return canonicalUrl;
}
+ protected void manualRedirect(Class<? extends BasePage> pageClass) {
+ redirect(pageClass, null);
+ }
+
+ protected void redirect(Class<? extends BasePage> pageClass, PageParameters parameters) {
+ String absoluteUrl = getCanonicalUrl(pageClass, parameters);
+ getRequestCycle().setRequestTarget(new RedirectRequestTarget(absoluteUrl));
+ }
+
protected String getLanguageCode() {
return GitBlitWebSession.get().getLocale().getLanguage();
}
@@ -495,4 +505,5 @@ public abstract class BasePage extends SessionPage {
}
return sb.toString();
}
+
}
diff --git a/src/main/java/com/gitblit/wicket/pages/EditMilestonePage.java b/src/main/java/com/gitblit/wicket/pages/EditMilestonePage.java
index 4ed77d83..801631e8 100644
--- a/src/main/java/com/gitblit/wicket/pages/EditMilestonePage.java
+++ b/src/main/java/com/gitblit/wicket/pages/EditMilestonePage.java
@@ -143,7 +143,7 @@ public class EditMilestonePage extends RepositoryPage {
}
if (success && app().tickets().updateMilestone(getRepositoryModel(), tm, createdBy)) {
- setResponsePage(TicketsPage.class, WicketUtils.newOpenTicketsParameter(repositoryName));
+ redirect(TicketsPage.class, WicketUtils.newOpenTicketsParameter(repositoryName));
} else {
// TODO error
}
diff --git a/src/main/java/com/gitblit/wicket/pages/EditTicketPage.java b/src/main/java/com/gitblit/wicket/pages/EditTicketPage.java
index 074ffa60..b55ce9c3 100644
--- a/src/main/java/com/gitblit/wicket/pages/EditTicketPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/EditTicketPage.java
@@ -331,13 +331,13 @@ public class EditTicketPage extends RepositoryPage {
if (ticket != null) {
TicketNotifier notifier = app().tickets().createNotifier();
notifier.sendMailing(ticket);
- setResponsePage(TicketsPage.class, WicketUtils.newObjectParameter(getRepositoryModel().name, "" + ticket.number));
+ redirect(TicketsPage.class, WicketUtils.newObjectParameter(getRepositoryModel().name, "" + ticket.number));
} else {
// TODO error
}
} else {
// nothing to change?!
- setResponsePage(TicketsPage.class, WicketUtils.newObjectParameter(getRepositoryModel().name, "" + ticket.number));
+ redirect(TicketsPage.class, WicketUtils.newObjectParameter(getRepositoryModel().name, "" + ticket.number));
}
}
});
diff --git a/src/main/java/com/gitblit/wicket/pages/NewMilestonePage.java b/src/main/java/com/gitblit/wicket/pages/NewMilestonePage.java
index cc331903..24a43120 100644
--- a/src/main/java/com/gitblit/wicket/pages/NewMilestonePage.java
+++ b/src/main/java/com/gitblit/wicket/pages/NewMilestonePage.java
@@ -108,7 +108,7 @@ public class NewMilestonePage extends RepositoryPage {
if (milestone != null) {
milestone.due = due;
app().tickets().updateMilestone(getRepositoryModel(), milestone, createdBy);
- throw new RestartResponseException(TicketsPage.class, WicketUtils.newOpenTicketsParameter(repositoryName));
+ redirect(TicketsPage.class, WicketUtils.newOpenTicketsParameter(repositoryName));
} else {
// TODO error
}
diff --git a/src/main/java/com/gitblit/wicket/pages/NewTicketPage.java b/src/main/java/com/gitblit/wicket/pages/NewTicketPage.java
index e6d9cb1e..f80a7d7e 100644
--- a/src/main/java/com/gitblit/wicket/pages/NewTicketPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/NewTicketPage.java
@@ -222,7 +222,8 @@ public class NewTicketPage extends RepositoryPage {
if (ticket != null) {
TicketNotifier notifier = app().tickets().createNotifier();
notifier.sendMailing(ticket);
- setResponsePage(TicketsPage.class, WicketUtils.newObjectParameter(getRepositoryModel().name, "" + ticket.number));
+
+ redirect(TicketsPage.class, WicketUtils.newObjectParameter(getRepositoryModel().name, "" + ticket.number));
} else {
// TODO error
}
diff --git a/src/main/java/com/gitblit/wicket/pages/RootPage.java b/src/main/java/com/gitblit/wicket/pages/RootPage.java
index 6a933b76..15e4304d 100644
--- a/src/main/java/com/gitblit/wicket/pages/RootPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/RootPage.java
@@ -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);
}
}
}