]> source.dussan.org Git - gitblit.git/commitdiff
issue 564: enable ticket page update on tomcat with redirects 245/head 38/238/2
authorkrulls <stephan.krull@ecg-leipzig.de>
Mon, 23 Feb 2015 17:24:45 +0000 (18:24 +0100)
committerkrulls <stephan.krull@ecg-leipzig.de>
Thu, 26 Feb 2015 09:31:14 +0000 (10:31 +0100)
issue 564: fix imports

issue 564

src/main/java/com/gitblit/wicket/pages/TicketPage.java
src/main/java/com/gitblit/wicket/panels/CommentPanel.java

index b690e4c05c142c4e0ebe116f7d377f1d53167577..19788f2731f4d1061ba430256d1defed19935317 100644 (file)
@@ -378,7 +378,7 @@ public class TicketPage extends RepositoryPage {
                                                                }\r
                                                                TicketModel update = app().tickets().updateTicket(repository, ticket.number, change);\r
                                                                app().tickets().createNotifier().sendMailing(update);\r
-                                                               setResponsePage(TicketsPage.class, getPageParameters());\r
+                                                               redirectTo(TicketsPage.class, getPageParameters());\r
                                                        }\r
                                                };\r
                                                String css = TicketsUI.getStatusClass(item.getModel().getObject());\r
@@ -442,7 +442,7 @@ public class TicketPage extends RepositoryPage {
                                                                }\r
                                                                TicketModel update = app().tickets().updateTicket(repository, ticket.number, change);\r
                                                                app().tickets().createNotifier().sendMailing(update);\r
-                                                               setResponsePage(TicketsPage.class, getPageParameters());\r
+                                                               redirectTo(TicketsPage.class, getPageParameters());\r
                                                        }\r
                                                };\r
                                                item.add(link);\r
@@ -487,7 +487,7 @@ public class TicketPage extends RepositoryPage {
                                                                }\r
                                                                TicketModel update = app().tickets().updateTicket(repository, ticket.number, change);\r
                                                                app().tickets().createNotifier().sendMailing(update);\r
-                                                               setResponsePage(TicketsPage.class, getPageParameters());\r
+                                                               redirectTo(TicketsPage.class, getPageParameters());\r
                                                        }\r
                                                };\r
                                                item.add(link);\r
@@ -560,7 +560,7 @@ public class TicketPage extends RepositoryPage {
                                                change.vote(user.username);\r
                                        }\r
                                        app().tickets().updateTicket(repository, ticket.number, change);\r
-                                       setResponsePage(TicketsPage.class, getPageParameters());\r
+                                       redirectTo(TicketsPage.class, getPageParameters());\r
                                }\r
                        };\r
                        add(link);\r
@@ -600,7 +600,7 @@ public class TicketPage extends RepositoryPage {
                                                change.watch(user.username);\r
                                        }\r
                                        app().tickets().updateTicket(repository, ticket.number, change);\r
-                                       setResponsePage(TicketsPage.class, getPageParameters());\r
+                                       redirectTo(TicketsPage.class, getPageParameters());\r
                                }\r
                        };\r
                        add(link);\r
@@ -1297,7 +1297,7 @@ public class TicketPage extends RepositoryPage {
                }\r
                TicketModel updatedTicket = app().tickets().updateTicket(getRepositoryModel(), ticket.number, change);\r
                app().tickets().createNotifier().sendMailing(updatedTicket);\r
-               setResponsePage(TicketsPage.class, getPageParameters());\r
+               redirectTo(TicketsPage.class, getPageParameters());\r
        }\r
 \r
        protected <X extends MarkupContainer> X setNewTarget(X x) {\r
@@ -1408,8 +1408,8 @@ public class TicketPage extends RepositoryPage {
                                                                GitBlitWebSession.get().cacheErrorMessage(msg);\r
                                                                logger.error(msg);\r
                                                        }\r
-\r
-                                                       setResponsePage(TicketsPage.class, getPageParameters());\r
+                                                       \r
+                                                       redirectTo(TicketsPage.class, getPageParameters());\r
                                                }\r
                                        };\r
                                        mergePanel.add(mergeButton);\r
index acf4dd9ae97af937039c852eddd976fec3261d9b..2bc088998456afcfefd83ad1bb9c9874db763379 100644 (file)
  */
 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();