]> source.dussan.org Git - gitblit.git/commitdiff
Use ajax buttons in the New|Edit Milestone pages
authorJames Moger <james.moger@gitblit.com>
Sun, 27 Apr 2014 23:49:33 +0000 (19:49 -0400)
committerJames Moger <james.moger@gitblit.com>
Thu, 1 May 2014 18:31:02 +0000 (14:31 -0400)
src/main/java/com/gitblit/wicket/pages/EditMilestonePage.java
src/main/java/com/gitblit/wicket/pages/NewMilestonePage.java

index b92ba8baa031bdaa116ca1c0ff0271e4f76ff1fd..967d8f35af53657b4f767895ccc100086a3c29ec 100644 (file)
@@ -21,6 +21,8 @@ import java.util.List;
 \r
 import org.apache.wicket.PageParameters;\r
 import org.apache.wicket.RestartResponseException;\r
+import org.apache.wicket.ajax.AjaxRequestTarget;\r
+import org.apache.wicket.ajax.markup.html.form.AjaxButton;\r
 import org.apache.wicket.extensions.markup.html.form.DateTextField;\r
 import org.apache.wicket.markup.html.form.Button;\r
 import org.apache.wicket.markup.html.form.DropDownChoice;\r
@@ -90,13 +92,26 @@ public class EditMilestonePage extends RepositoryPage {
                setStatelessHint(false);\r
                setOutputMarkupId(true);\r
 \r
-               Form<Void> form = new Form<Void>("editForm") {\r
+               Form<Void> form = new Form<Void>("editForm");\r
+               add(form);\r
+\r
+               nameModel = Model.of(tm.name);\r
+               dueModel = Model.of(tm.due);\r
+               statusModel = Model.of(tm.status);\r
+               notificationModel = Model.of(true);\r
+\r
+               form.add(new TextField<String>("name", nameModel));\r
+               form.add(new DateTextField("due", dueModel, "yyyy-MM-dd"));\r
+\r
+               List<Status> statusChoices = Arrays.asList(Status.Open, Status.Closed);\r
+               form.add(new DropDownChoice<TicketModel.Status>("status", statusModel, statusChoices));\r
+\r
+               form.add(new AjaxButton("save") {\r
 \r
                        private static final long serialVersionUID = 1L;\r
 \r
                        @Override\r
-                       protected void onSubmit() {\r
-\r
+                       protected void onSubmit(AjaxRequestTarget target, Form<?> form) {\r
                                String name = nameModel.getObject();\r
                                if (StringUtils.isEmpty(name)) {\r
                                        return;\r
@@ -126,21 +141,7 @@ public class EditMilestonePage extends RepositoryPage {
                                        // TODO error\r
                                }\r
                        }\r
-               };\r
-               add(form);\r
-\r
-               nameModel = Model.of(tm.name);\r
-               dueModel = Model.of(tm.due);\r
-               statusModel = Model.of(tm.status);\r
-               notificationModel = Model.of(true);\r
-\r
-               form.add(new TextField<String>("name", nameModel));\r
-               form.add(new DateTextField("due", dueModel, "yyyy-MM-dd"));\r
-\r
-               List<Status> statusChoices = Arrays.asList(Status.Open, Status.Closed);\r
-               form.add(new DropDownChoice<TicketModel.Status>("status", statusModel, statusChoices));\r
-\r
-               form.add(new Button("save"));\r
+               });\r
                Button cancel = new Button("cancel") {\r
                        private static final long serialVersionUID = 1L;\r
 \r
index 4c3937869984cef62f612a6acbdb9dc6a52567a6..d6e34cb08011d55b650a1b871154282fd147b481 100644 (file)
@@ -19,6 +19,8 @@ import java.util.Date;
 \r
 import org.apache.wicket.PageParameters;\r
 import org.apache.wicket.RestartResponseException;\r
+import org.apache.wicket.ajax.AjaxRequestTarget;\r
+import org.apache.wicket.ajax.markup.html.form.AjaxButton;\r
 import org.apache.wicket.extensions.markup.html.form.DateTextField;\r
 import org.apache.wicket.markup.html.form.Button;\r
 import org.apache.wicket.markup.html.form.Form;\r
@@ -68,13 +70,21 @@ public class NewMilestonePage extends RepositoryPage {
                setStatelessHint(false);\r
                setOutputMarkupId(true);\r
 \r
-               Form<Void> form = new Form<Void>("editForm") {\r
+               Form<Void> form = new Form<Void>("editForm");\r
+               add(form);\r
+\r
+               nameModel = Model.of("");\r
+               dueModel = Model.of(new Date(System.currentTimeMillis() + TimeUtils.ONEDAY));\r
+\r
+               form.add(new TextField<String>("name", nameModel));\r
+               form.add(new DateTextField("due", dueModel, "yyyy-MM-dd"));\r
+\r
+               form.add(new AjaxButton("create") {\r
 \r
                        private static final long serialVersionUID = 1L;\r
 \r
                        @Override\r
-                       protected void onSubmit() {\r
-\r
+                       protected void onSubmit(AjaxRequestTarget target, Form<?> form) {\r
                                String name = nameModel.getObject();\r
                                if (StringUtils.isEmpty(name)) {\r
                                        return;\r
@@ -94,16 +104,8 @@ public class NewMilestonePage extends RepositoryPage {
                                        // TODO error\r
                                }\r
                        }\r
-               };\r
-               add(form);\r
-\r
-               nameModel = Model.of("");\r
-               dueModel = Model.of(new Date(System.currentTimeMillis() + TimeUtils.ONEDAY));\r
-\r
-               form.add(new TextField<String>("name", nameModel));\r
-               form.add(new DateTextField("due", dueModel, "yyyy-MM-dd"));\r
+               });\r
 \r
-               form.add(new Button("create"));\r
                Button cancel = new Button("cancel") {\r
                        private static final long serialVersionUID = 1L;\r
 \r