summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkrulls <stephan.krull@ecg-leipzig.de>2015-02-23 18:24:45 +0100
committerkrulls <stephan.krull@ecg-leipzig.de>2015-02-26 10:31:14 +0100
commit47a544e3ffcd20f968a505b0efa61e99cf3af46a (patch)
tree9fd49a9377fb41a026236b67c57b3f2face18d42
parentc71e8bd9c4e55fc4f8eddc434066ab2414a9b659 (diff)
downloadgitblit-47a544e3ffcd20f968a505b0efa61e99cf3af46a.tar.gz
gitblit-47a544e3ffcd20f968a505b0efa61e99cf3af46a.zip
issue 564: enable ticket page update on tomcat with redirects
issue 564: fix imports issue 564
-rw-r--r--src/main/java/com/gitblit/wicket/pages/TicketPage.java16
-rw-r--r--src/main/java/com/gitblit/wicket/panels/CommentPanel.java23
2 files changed, 30 insertions, 9 deletions
diff --git a/src/main/java/com/gitblit/wicket/pages/TicketPage.java b/src/main/java/com/gitblit/wicket/pages/TicketPage.java
index b690e4c0..19788f27 100644
--- a/src/main/java/com/gitblit/wicket/pages/TicketPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/TicketPage.java
@@ -378,7 +378,7 @@ public class TicketPage extends RepositoryPage {
}
TicketModel update = app().tickets().updateTicket(repository, ticket.number, change);
app().tickets().createNotifier().sendMailing(update);
- setResponsePage(TicketsPage.class, getPageParameters());
+ redirectTo(TicketsPage.class, getPageParameters());
}
};
String css = TicketsUI.getStatusClass(item.getModel().getObject());
@@ -442,7 +442,7 @@ public class TicketPage extends RepositoryPage {
}
TicketModel update = app().tickets().updateTicket(repository, ticket.number, change);
app().tickets().createNotifier().sendMailing(update);
- setResponsePage(TicketsPage.class, getPageParameters());
+ redirectTo(TicketsPage.class, getPageParameters());
}
};
item.add(link);
@@ -487,7 +487,7 @@ public class TicketPage extends RepositoryPage {
}
TicketModel update = app().tickets().updateTicket(repository, ticket.number, change);
app().tickets().createNotifier().sendMailing(update);
- setResponsePage(TicketsPage.class, getPageParameters());
+ redirectTo(TicketsPage.class, getPageParameters());
}
};
item.add(link);
@@ -560,7 +560,7 @@ public class TicketPage extends RepositoryPage {
change.vote(user.username);
}
app().tickets().updateTicket(repository, ticket.number, change);
- setResponsePage(TicketsPage.class, getPageParameters());
+ redirectTo(TicketsPage.class, getPageParameters());
}
};
add(link);
@@ -600,7 +600,7 @@ public class TicketPage extends RepositoryPage {
change.watch(user.username);
}
app().tickets().updateTicket(repository, ticket.number, change);
- setResponsePage(TicketsPage.class, getPageParameters());
+ redirectTo(TicketsPage.class, getPageParameters());
}
};
add(link);
@@ -1297,7 +1297,7 @@ public class TicketPage extends RepositoryPage {
}
TicketModel updatedTicket = app().tickets().updateTicket(getRepositoryModel(), ticket.number, change);
app().tickets().createNotifier().sendMailing(updatedTicket);
- setResponsePage(TicketsPage.class, getPageParameters());
+ redirectTo(TicketsPage.class, getPageParameters());
}
protected <X extends MarkupContainer> X setNewTarget(X x) {
@@ -1408,8 +1408,8 @@ public class TicketPage extends RepositoryPage {
GitBlitWebSession.get().cacheErrorMessage(msg);
logger.error(msg);
}
-
- setResponsePage(TicketsPage.class, getPageParameters());
+
+ redirectTo(TicketsPage.class, getPageParameters());
}
};
mergePanel.add(mergeButton);
diff --git a/src/main/java/com/gitblit/wicket/panels/CommentPanel.java b/src/main/java/com/gitblit/wicket/panels/CommentPanel.java
index acf4dd9a..2bc08899 100644
--- a/src/main/java/com/gitblit/wicket/panels/CommentPanel.java
+++ b/src/main/java/com/gitblit/wicket/panels/CommentPanel.java
@@ -15,12 +15,15 @@
*/
package com.gitblit.wicket.panels;
+import org.apache.wicket.PageParameters;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.form.AjaxButton;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
+import org.apache.wicket.protocol.http.RequestUtils;
+import org.apache.wicket.request.target.basic.RedirectRequestTarget;
import com.gitblit.models.RepositoryModel;
import com.gitblit.models.TicketModel;
@@ -79,7 +82,7 @@ public class CommentPanel extends BasePanel {
TicketModel updatedTicket = app().tickets().updateTicket(repository, ticket.number, newComment);
if (updatedTicket != null) {
app().tickets().createNotifier().sendMailing(updatedTicket);
- setResponsePage(pageClass, WicketUtils.newObjectParameter(updatedTicket.repository, "" + ticket.number));
+ redirectTo(pageClass, WicketUtils.newObjectParameter(updatedTicket.repository, "" + ticket.number));
} else {
error("Failed to add comment!");
}
@@ -87,6 +90,24 @@ public class CommentPanel extends BasePanel {
// TODO update comment
}
}
+
+ /**
+ * Steal from BasePage to realize redirection.
+ *
+ * @see BasePage
+ * @author krulls@GitHub; ECG Leipzig GmbH, Germany, 2015
+ *
+ * @param pageClass
+ * @param parameters
+ * @return
+ */
+ private void redirectTo(Class<? extends BasePage> pageClass, PageParameters parameters)
+ {
+ String relativeUrl = urlFor(pageClass, parameters).toString();
+ String canonicalUrl = RequestUtils.toAbsolutePath(relativeUrl);
+ getRequestCycle().setRequestTarget(new RedirectRequestTarget(canonicalUrl));
+ }
+
}.setVisible(ticket != null && ticket.number > 0));
final IModel<String> markdownPreviewModel = Model.of();