From: Kai Moritz Date: Tue, 21 Jan 2020 22:12:17 +0000 (+0100) Subject: Added a checkbox, that is stored in a field of an inner class X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=c714fe0e5f5ac2ef7933948f51dbb5ee4d3023cb;p=demos%2Fspring-boot Added a checkbox, that is stored in a field of an inner class --- diff --git a/src/main/java/de/juplo/demo/DemoController.java b/src/main/java/de/juplo/demo/DemoController.java index 483ca88..3f8d0dd 100644 --- a/src/main/java/de/juplo/demo/DemoController.java +++ b/src/main/java/de/juplo/demo/DemoController.java @@ -8,7 +8,7 @@ import org.springframework.web.bind.annotation.RequestMapping; /** - * Controller to demonstrate the behavior of the checkbox + * Controller to demonstrate the behavior of checkboxes * @author Kai Moritz */ @Controller @@ -18,7 +18,7 @@ public class DemoController @RequestMapping("/") public String display(@ModelAttribute Form form) { - log.info("option={}", form.option); + log.info("option={}, inner={}", form.option, form.inner.option); return "form"; } } diff --git a/src/main/java/de/juplo/demo/Form.java b/src/main/java/de/juplo/demo/Form.java index 5bd5388..e7a40af 100644 --- a/src/main/java/de/juplo/demo/Form.java +++ b/src/main/java/de/juplo/demo/Form.java @@ -5,11 +5,18 @@ import lombok.Data; /** - * Simple form with a single checkbox + * Simple form to demonstrate the behavior of checkboxes * @author Kai Moritz */ @Data public class Form +{ + Boolean option; + Inner inner = new Inner(); +} + +@Data +class Inner { Boolean option; } diff --git a/src/main/resources/templates/form.html b/src/main/resources/templates/form.html index b04d254..10ebfaa 100644 --- a/src/main/resources/templates/form.html +++ b/src/main/resources/templates/form.html @@ -20,6 +20,10 @@ +
+ + +