WIP
authorKai Moritz <kai@juplo.de>
Tue, 21 Jan 2020 20:42:15 +0000 (21:42 +0100)
committerKai Moritz <kai@juplo.de>
Fri, 7 Apr 2023 11:21:44 +0000 (13:21 +0200)
src/main/java/de/juplo/demo/DemoController.java
src/main/resources/templates/form.html

index 7c65a60..da09321 100644 (file)
@@ -33,7 +33,7 @@ public class DemoController
     return "form";
   }
 
-  @RequestMapping(path = "/", params = "card=add")
+  @RequestMapping(path = "/", params = { "card=add", "!add", "!remove" })
   public String addCard(@ModelAttribute Form form)
   {
     Integer next =
@@ -54,7 +54,7 @@ public class DemoController
     return "form";
   }
 
-  @RequestMapping(path = "/", params = "card!=add")
+  @RequestMapping(path = "/", params = { "card!=add", "!add", "!remove" })
   public String removeCard(@ModelAttribute Form form, @RequestParam Integer card)
   {
     Map<String, Boolean> content = form.cards.remove(card);
@@ -67,7 +67,7 @@ public class DemoController
     return "form";
   }
 
-  @RequestMapping(path = "/", params = "add")
+  @RequestMapping(path = "/", params = { "!card", "add", "!remove" })
   public String addRow(@ModelAttribute Form form, @RequestParam Integer add)
   {
     LOG.info("Adding row {} to card #{}", form.names.get(add), add);
@@ -80,7 +80,7 @@ public class DemoController
     return "form";
   }
 
-  @RequestMapping(path = "/", params = "remove")
+  @RequestMapping(path = "/", params = { "!card", "!add", "remove" })
   public String removeRow(@ModelAttribute Form form, @RequestParam String remove)
   {
     String[] parts = remove.split(":", 2);
index eb6fb24..7a1ea54 100644 (file)
@@ -18,7 +18,7 @@
             <div class="card-text">
               <div class="form-group" th:each="row : ${card.value.entrySet()}">
                 <input type="checkbox" id="x" class="form-control" th:field="*{cards[__${card.key}__][__${row.key}__]}" />
-                <label for="x" th:for="${#ids.prev('cards[__${card.key}__][__${row.key}__]')}" th:text="${row.value}">ROW_NAME</label>
+                <label for="x" th:for="${#ids.next('cards[__${card.key}__][__${row.key}__]')}" th:text="${row.key}">ROW_NAME</label>
                 <button type="submit" name="remove" class="btn btn-primary" th:value="|${card.key}:${row.key}|">Remove</button>
               </div>
               <div class="form-group">