You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Thomas Götz <to...@decoded.de> on 2012/09/12 11:33:38 UTC

wicket-select2 as AutoCompleteTextField replacement

I want to use wicket-select2 as a replacement for Wicket's AutoCompleteTextField. Is it somehow possible to accept user input that is not contained in the list of choices? Say, my choices list returns [A, B, C] but user may also enter "D" in the textfield. How can I achieve this?

   -Tom


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: wicket-select2 as AutoCompleteTextField replacement

Posted by Sébastien Gautrin <sg...@telemetris.com>.
Hi,

If you only need a static list of initial choices (non ajax), you 
should be able to simply use select2's tagging support with something 
like (didn't test it):
// model is your IModel<String> for the selected data
Select2Choice<String> choice = new Select2Choice<String>("choice", 
model);
choice.getSettings().setTags("A", "B", "C");

You can of course also use a Select2MultiChoice for multiple choices.

Now if you need Ajax support, it's somewhat more complex, though for 
the simple case where you don't need to mix static choices and ajax, 
you could use a standard Select2Choice (or MultiChoice), and in the 
query method of your choice provider prepend the query string to the 
list of results.


On Wed 12 Sep 2012 11:33:38 CEST, Thomas Götz wrote:
> I want to use wicket-select2 as a replacement for Wicket's AutoCompleteTextField. Is it somehow possible to accept user input that is not contained in the list of choices? Say, my choices list returns [A, B, C] but user may also enter "D" in the textfield. How can I achieve this?
>
>     -Tom
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: wicket-select2 as AutoCompleteTextField replacement

Posted by Thomas Götz <to...@decoded.de>.
Ok, will try that, thanks!

   -Tom

On 12.09.2012, at 17:23, Igor Vaynberg <ig...@gmail.com> wrote:

> you need to define your own createSearchChoice function and pass it to
> the config. see the docs on the demo site.
> 
> -igor
> 
> On Wed, Sep 12, 2012 at 2:33 AM, Thomas Götz <to...@decoded.de> wrote:
>> I want to use wicket-select2 as a replacement for Wicket's AutoCompleteTextField. Is it somehow possible to accept user input that is not contained in the list of choices? Say, my choices list returns [A, B, C] but user may also enter "D" in the textfield. How can I achieve this?
>> 
>>   -Tom


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: wicket-select2 as AutoCompleteTextField replacement

Posted by Igor Vaynberg <ig...@gmail.com>.
you need to define your own createSearchChoice function and pass it to
the config. see the docs on the demo site.

-igor

On Wed, Sep 12, 2012 at 2:33 AM, Thomas Götz <to...@decoded.de> wrote:
> I want to use wicket-select2 as a replacement for Wicket's AutoCompleteTextField. Is it somehow possible to accept user input that is not contained in the list of choices? Say, my choices list returns [A, B, C] but user may also enter "D" in the textfield. How can I achieve this?
>
>    -Tom
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org