WIP
authorKai Moritz <kai@juplo.de>
Tue, 21 Jan 2020 20:07:09 +0000 (21:07 +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 a83a4b1..cc2fcba 100644 (file)
@@ -32,7 +32,7 @@ public class DemoController
     return "form";
   }
 
-  @RequestMapping(path = "/", params = "add=card")
+  @RequestMapping(path = "/", params = "card=add")
   public String addCard(@ModelAttribute Form form)
   {
     Integer next =
@@ -46,17 +46,15 @@ public class DemoController
     return "form";
   }
 
-  @RequestMapping(path = "/", params = "remove=card")
-  public String removeCard(
-      @ModelAttribute Form form,
-      @RequestParam Integer card)
+  @RequestMapping(path = "/", params = "card!=add")
+  public String removeCard(@ModelAttribute Form form, @RequestParam Integer card)
   {
     Map<String, Boolean> content = form.cards.remove(card);
     LOG.info("Removed card #{} with content: {}", card, content);
     return "form";
   }
 
-  @RequestMapping(path = "/", params = "add!=card")
+  @RequestMapping(path = "/", params = "add")
   public String addRow(@ModelAttribute Form form, @RequestParam Integer add)
   {
     LOG.info("Adding row {} to card #{}", form.row.get(add), add);
@@ -64,7 +62,7 @@ public class DemoController
     return "form";
   }
 
-  @RequestMapping(path = "/", params = "remove!=card")
+  @RequestMapping(path = "/", params = "remove")
   public String removeRow(@ModelAttribute Form form, @RequestParam String remove)
   {
     String[] parts = remove.split(":", 2);
index f009beb..4105325 100644 (file)
               </div>
               <div class="form-group">
                 <input type="text" th:field="*{row[__${card.key}__]}" />
-                <button type="submit" name="add" value="row" class="btn btn-primary">Add Row</button>
+                <button type="submit" name="add" th:value="${card.key}" class="btn btn-primary">Add Row</button>
               </div>
             </div>
             <div class="card-footer">
-              <button type="submit" name="remove" value="card" class="btn btn-primary">Remove Card</button>
+              <button type="submit" name="card" th:value="${card.key}" class="btn btn-primary">Remove Card</button>
             </div>
           </div>
         </div>
-        <p><button type="submit" name="add" value="card" class="btn btn-primary">Add Card</button></p>
+        <p><button type="submit" name="card" value="add" class="btn btn-primary">Add Card</button></p>
       </form>
     </main>
   </body>