From: Kai Moritz Date: Tue, 21 Jan 2020 21:27:20 +0000 (+0100) Subject: Implemented a form with a single checkbox to study its behavior X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=ca1ddb54ae8bf1908726a1e8ace2dbfb87266bee;p=demos%2Fspring-boot Implemented a form with a single checkbox to study its behavior --- diff --git a/pom.xml b/pom.xml index fa19ce0..0ad8f78 100644 --- a/pom.xml +++ b/pom.xml @@ -26,6 +26,11 @@ org.springframework.boot spring-boot-starter-webflux + + org.projectlombok + lombok + provided + org.springframework.boot diff --git a/src/main/java/de/juplo/demo/DemoController.java b/src/main/java/de/juplo/demo/DemoController.java new file mode 100644 index 0000000..483ca88 --- /dev/null +++ b/src/main/java/de/juplo/demo/DemoController.java @@ -0,0 +1,24 @@ +package de.juplo.demo; + + +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; + + +/** + * Controller to demonstrate the behavior of the checkbox + * @author Kai Moritz + */ +@Controller +@Slf4j +public class DemoController +{ + @RequestMapping("/") + public String display(@ModelAttribute Form form) + { + log.info("option={}", form.option); + return "form"; + } +} diff --git a/src/main/java/de/juplo/demo/Form.java b/src/main/java/de/juplo/demo/Form.java new file mode 100644 index 0000000..5bd5388 --- /dev/null +++ b/src/main/java/de/juplo/demo/Form.java @@ -0,0 +1,15 @@ +package de.juplo.demo; + + +import lombok.Data; + + +/** + * Simple form with a single checkbox + * @author Kai Moritz + */ +@Data +public class Form +{ + Boolean option; +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 8b13789..28b0607 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1 +1 @@ - +logging.level.=INFO diff --git a/src/main/resources/templates/form.html b/src/main/resources/templates/form.html new file mode 100644 index 0000000..b04d254 --- /dev/null +++ b/src/main/resources/templates/form.html @@ -0,0 +1,32 @@ + + + + + + Demo: Behavior Of A Checkbox + + + + +
+
+
+
Select / unselect the option and submit the form...
+
+
+
+ + +
+
+
+ +
+
+
+ +