Reputation:
I am looking for the simplest way to apply autocomplete to a wicket 8 dropdownchoice with a list of names.
I just want a hint..
List<User> list = getUsers();
final DropDownChoice<User> dropdown = new DropDownChoice<User>("dropdown",
new PropertyModel<User>(this, "selected"), list, renderer) { //code };
Upvotes: 0
Views: 328
Reputation: 17513
DropDownChoice component produces plain HTML <select>
element.
Your options are:
$.select2('#yourSelectId')
manuallyUpvotes: 0
Reputation:
I am using this piece of code but I am not sure if it works well..
dropdown.add(new AutoCompleteBehavior(new StringAutoCompleteRenderer()){
/**
*
*/
private static final long serialVersionUID = 1L;
@Override
protected Iterator getChoices(String input) {
List<String> completions = new ArrayList();
Iterator iter = list.iterator();
while(iter.hasNext()){
String user = ((User) iter.next()).getAddress();
if(user.startsWith(input)){
completions.add(user);
}
}
return completions.iterator();
}
});
Upvotes: 0