<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.projectlombok</groupId>
+ <artifactId>lombok</artifactId>
+ <scope>provided</scope>
+ </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
--- /dev/null
+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";
+ }
+}
--- /dev/null
+<!DOCTYPE html>
+<html lang="en" xmlns:th="http://www.thymeleaf.org">
+ <head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
+ <title>Demo: Behavior Of A Checkbox</title>
+ <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
+ </head>
+ <body>
+ <nav class="navbar navbar-dark bg-primary navbar-expand navbar-dark flex-column">
+ <h1 class="navbar-brand">Demo: Behavior Of A Checkbox</h1>
+ </nav>
+ <main class="container mt-5">
+ <form action="#" th:action="@{/}" th:object="${form}" method="get">
+ <div class="card my-3">
+ <div class="card-header">Select / unselect the option and submit the form...</div>
+ <div class="card-body">
+ <div class="card-text">
+ <div class="form-group">
+ <input type="checkbox" class="form-check-label" th:field="*{option}" />
+ <label class="form-check-label" th:for="${#ids.prev('option')}">Fancy Option To Choose</label>
+ </div>
+ </div>
+ </div>
+ <div class="card-footer">
+ <button type="submit" class="btn btn-primary">Submit</button>
+ </div>
+ </div>
+ </form>
+ </main>
+ </body>
+</html>