Hi Heikki,
Basically the AutoCompleteTextField is a TextField, so you can cannot
restrict - strictly speaking - the user choice like you can do with a
DropDownChoice/DropDownList for instance...
However...
If the ACTF choice list is *type of String*, you can validate the user
choice, and report an error if the choice is not part of the list:
form.add(autocomplete.setRequired(true).add(new
IValidator<String>() {
private static final long serialVersionUID = 1L;
@Override
public void validate(IValidatable<String> validatable) {
//TODO: customize the validation process here:
if (!MY_LIST.contains(validatable.getValue())) {
validatable.error(new ValidationError("not a valid
choice!"));
}
}
}));
Second option: If the ACTF choice list is *type of beans*, then you can
check whether the modelobject is null in form#onSubmit. But as it is a
little bit late in the form processing (the components and form validation
already succeed) , prefer the option #1 if you can
Hope this helps,
Sebastien.
On Tue, Apr 16, 2013 at 5:36 PM, Igor Vaynberg <[email protected]>wrote:
> you can try using this:
>
> https://github.com/ivaynberg/wicket-select2
>
> -igor
>
> On Tue, Apr 16, 2013 at 8:30 AM, heikki <[email protected]> wrote:
> > hello,
> >
> > I've an autocomplete textfield (this one:
> > com.googlecode.wicket.jquery.ui.form.autocomplete.AutoCompleteTextField)
> and
> > I'd like to restrict users to select one of the values presented in its
> > choices.
> >
> > As it is, you can also input values that are not in the choices.
> >
> > Is there an easy way to do this ?
> >
> > Kind regards
> > Heikki Doeleman
> >
> >
> >
> > --
> > View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/How-to-force-user-to-select-from-AutoComplete-choices-tp4658033.html
> > Sent from the Users forum mailing list archive at Nabble.com.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [email protected]
> > For additional commands, e-mail: [email protected]
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>