DynamicListModule
Submit comma-separated values to render a different list.
Dynamic list
- Compose
- Render
Java composition
String value = "Compose, Render";
Component module = DynamicListModule.create().withTitle("Dynamic list").withListItems(List.of(value.split(",")));
new Div().withChild(Form.create().withAction("/demos/api/dynamic").withMethod(Form.Method.POST)
.withHxPost("/demos/api/dynamic").withHxTarget("#dynamic-result").withHxSwap("outerHTML")
.withChild(new HtmlTag("input", true).withAttribute("type", "hidden")
.withAttribute("name", "kind").withAttribute("value", "dynamic-list"))
.addField("Value", TextInput.create("value").withValue(value).required())
.withChild(Button.submit("Update dynamic-list")))
.withChild(new Div().withId("dynamic-result").withAttribute("aria-live", "polite").withChild(module));
// POST /demos/api/dynamic selects the same module with the submitted value.