* Otherwise, these options are always automatically readded immediately, when
they are removed
* A request is considered as new, if it contains the parameter "name", which
always exists, if a submit is triggered
package de.juplo.demo;
+import java.util.LinkedHashMap;
import java.util.stream.Collectors;
+import java.util.stream.Stream;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
@Slf4j
public class DemoController
{
+ @ModelAttribute
+ public Form createForm(
+ @RequestParam(name = "name", required = false) String param)
+ {
+ Form form = new Form();
+ if (param == null)
+ {
+ form.map =
+ new LinkedHashMap<>(
+ Stream
+ .of( "foo", "bar" )
+ .collect(Collectors.toMap(a -> a, a -> false)));
+ }
+ return form;
+ }
+
@RequestMapping("/")
public String display(@ModelAttribute Form form)
{
package de.juplo.demo;
-import java.util.LinkedHashMap;
import java.util.Map;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
import lombok.Data;
{
Boolean option;
Inner inner = new Inner();
- Map<String, Boolean> map =
- new LinkedHashMap<>(
- Stream.of( "foo", "bar" ).collect(Collectors.toMap(a -> a, a -> false)));
+ Map<String, Boolean> map;
}
@Data