DUE TO SPAM, SIGN-UP IS DISABLED. Goto Selfserve wiki signup and request an account.
| Excerpt | ||
|---|---|---|
| ||
How to use checkboxes to select items in a listview |
Using Use checkboxes to select items in a listview is a common thing to do. For example, you want to select items to delete from a list.
...
The wrapper:
| Code Block |
|---|
/** {panel} * name is the wrapped object that could be your business object. * the selected property is just here to record whether the checkbox for * it was selected. */ {panel} private class NameWrapper implements Serializable { private String name; private Boolean selected = Boolean.FALSE; public NameWrapper(String wrapped) { this.name = wrapped; } public Boolean getSelected() { return selected; } public void setSelected(Boolean selected) { this.selected = selected; } public String getName() { return name; } public void setName(String wrapped) { this.name = wrapped; } public String toString() { return name + ": " + selected; } } |
...
And finally the HTML page (FormInput.html):
| Code Block | ||||
|---|---|---|---|---|
| ||||
<html> <head> {panel} <title>Test</title> {panel} </head> <body> {panel} <form wicket:id="inputForm" id="inputForm"> <fieldset> <legend>Checkbox test</legend> <span wicket:id="list"> <span wicket:id="name">test</span> <input wicket:id="check" type="checkbox" /> </span> <input type="submit" value="save" /> </fieldset> </form> <div> <span wicket:id="feedback" /> </div> {panel} </body> </html> |
We've been discussing making working with checkboxes for selections from a list even easier in future, but this example is how I would do it right now.