You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Martin Letendre <le...@gmail.com> on 2009/07/15 22:24:40 UTC
CheckBoxMultipleChoice Construtor Nigthmare...
I am trying to use this constructor
http://wicket.apache.org/docs/1.4/org/apache/wicket/markup/html/form/CheckBoxMultipleChoice.html#CheckBoxMultipleChoice%28java.lang.String,%20org.apache.wicket.model.IModel,%20java.util.List%29
Here is my best result
// Days is an enum and is Serializable
List<Day> daysOfWeek = Arrays.asList(Day.values());
CheckBoxMultipleChoice<Day> daysSelector = new
CheckBoxMultipleChoice<Day>("daysSelector", *null*, daysOfWeek);
But I am not able to generate a suitable model for this constructor (see the
*null *parameter ). I found the typing really complex. Can someone can
provide an example.
Thanks.
Re: CheckBoxMultipleChoice Construtor Nigthmare...
Posted by Marcin Palka <ma...@gmail.com>.
Hi,
Try it this way.
<html
xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.3-strict.dtd"
>
<head>
<title>Wicket Quickstart Archetype Homepage</title>
</head>
<body>
<form wicket:id="form">
<input type="submit" value="submit"/>
</form>
<div wicket:id="listview">
item
</div>
</body>
</html>
public class HomePage extends WebPage {
private static final long serialVersionUID = 3555903561445555986L;
//this lists holds selected items
ArrayList<String> chosen = new ArrayList<String>();
//this list provides available choices
List<String> choices = Arrays.asList(new String[]{"One", "Two",
"Three"});
public HomePage(final PageParameters parameters) {
Form form = new Form("form");
//add a checkbox group
form.add(new CheckBoxMultipleChoice("choices", new Model(chosen),
choices));
add(form);
//render selected items in a listview
add(new ListView<String>("listview", chosen) {
@Override
protected void populateItem(ListItem<String> item) {
item.add(new Label("item", item.getModelObject()));
}
});
}
}
cheers
Marcin
--
View this message in context: http://www.nabble.com/CheckBoxMultipleChoice-Construtor-Nigthmare...-tp24505133p24505999.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org