summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Moger <james.moger@gitblit.com>2015-02-26 08:16:44 -0500
committerJames Moger <james.moger@gitblit.com>2015-02-26 08:16:44 -0500
commit3bddeebcebf197ed6f8f785b26fba02faebd5344 (patch)
tree6fb7042a5667406c6e1d5badf15f414fd8d501e3
parent5ec94c4282ed3630b7b4cd0fb5db62c20ce46d9d (diff)
parent47a544e3ffcd20f968a505b0efa61e99cf3af46a (diff)
downloadgitblit-3bddeebcebf197ed6f8f785b26fba02faebd5344.tar.gz
gitblit-3bddeebcebf197ed6f8f785b26fba02faebd5344.zip
Merge branch 'ticket/238' into develop
-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 4890874a..254d3c9b 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);
@@ -566,7 +566,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);
@@ -606,7 +606,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);
@@ -1303,7 +1303,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) {
@@ -1414,8 +1414,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();