Reputation: 2345
Is there a way to select multiple values in a dropdown in Apcahe Wicket using PropertyModel?
Upvotes: 2
Views: 1802
Reputation: 208
You can use ListMultipleChoice.
Say you have a list of users to which you want to populate in the multiselect drop down. You can do something like this:
ListMultipleChoice<?> multiChoice = new ListMultipleChoice<Object>
("usermultiSelect",
(IModel<? extends Collection<Object>>) new PropertyModel<Object>(properties,"selectedUsers"),
users);
Furthermore you can register on change listener to do some stuff with the selected data
multichoice.add(new AjaxFormComponentUpdatingBehavior("onchange") {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
List<User> users = (List<User>) properties.get("selectedUsers");
// do whatever you want to do with the users list
}
};
Upvotes: 1
Reputation: 270
You could use wicket Palette or use Select2. https://github.com/ivaynberg/wicket-select2/tree/master/wicket-select2-examples
Upvotes: 0