You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Daniele Dellafiore <il...@gmail.com> on 2012/08/01 12:31:18 UTC
AutocompleteTextField and object (not just String)
Hi.
I'm sure I'm talking about something that has already been discussed
here and on stackoverflow a lot, but still I haven't found a solution.
I do not understand how AutocompleteTextField works when dealing with
list of objects that are not just strings. Other wicket components
like DropDown has a clear pattern: the renderer is used only for
rendering purpose, there's a model to store selection and a model to
store choices options.
Still, I can't figure out how to do the very same thing with
AutocompleteTextField.
The best I can get is:
TextField codeField = new AutoCompleteTextField<JSONObject>("code",
model, JSONObject.class, renderer,
new AutoCompleteSettings());
I'm using an AbstractAutoCompleteTextRenderer and a PropertyModel
binded to a JSONObject variable.
It all works but when I submit the form, it says me that the selected
string is not a valid JSONObject, so he cannot attach it to the field.
the ITerator returned by AutocompleteTextField.getChoices(String
input) is an Iterator of JSONObject.
I expect that when I submit, the setObject receives the selected
JSONObject, not the String I do render using a specific Renderer.
How can that be done?
Thanks anyone for help.
--
Daniele Dellafiore
http://danieledellafiore.net
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: AutocompleteTextField and object (not just String)
Posted by Giovanni Cuccu <gi...@cup2000.it>.
ciao,
I think Autocompletetextfield deals only with String.
IIRC there is a objectautocomplete in wicketstuff.
I did not use it personally but I suppose that does what you need.
Giovanni
Il 01/08/12 12.31, Daniele Dellafiore ha scritto:
> Hi.
>
> I'm sure I'm talking about something that has already been discussed
> here and on stackoverflow a lot, but still I haven't found a solution.
>
> I do not understand how AutocompleteTextField works when dealing with
> list of objects that are not just strings. Other wicket components
> like DropDown has a clear pattern: the renderer is used only for
> rendering purpose, there's a model to store selection and a model to
> store choices options.
>
> Still, I can't figure out how to do the very same thing with
> AutocompleteTextField.
>
> The best I can get is:
> TextField codeField = new AutoCompleteTextField<JSONObject>("code",
> model, JSONObject.class, renderer,
> new AutoCompleteSettings());
>
>
> I'm using an AbstractAutoCompleteTextRenderer and a PropertyModel
> binded to a JSONObject variable.
> It all works but when I submit the form, it says me that the selected
> string is not a valid JSONObject, so he cannot attach it to the field.
>
> the ITerator returned by AutocompleteTextField.getChoices(String
> input) is an Iterator of JSONObject.
> I expect that when I submit, the setObject receives the selected
> JSONObject, not the String I do render using a specific Renderer.
>
> How can that be done?
>
> Thanks anyone for help.
>
--
Giovanni Cuccu
Responsabile area sviluppo - CUP 2000 Spa
Via del Borgo di S. Pietro, 90/c - 40126 Bologna
e-mail: giovanni.cuccu _at_ cup2000.it
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: AutocompleteTextField and object (not just String)
Posted by Igor Vaynberg <ig...@gmail.com>.
probably easier to use
https://github.com/ivaynberg/wicket-select2
which integrates
http://ivaynberg.github.com/select2/
rather then writing your own from scratch...
-igor
On Mon, Aug 6, 2012 at 3:36 PM, Per <pe...@hamburg.de> wrote:
> Hi Daniele,
>
> while I don't have the answer to your question, here's a recent blogpost
> about how we implemented a reusable wicket autocomplete field. We were not
> entirely satisfied by the solutions we found about a year ago, so we cooked
> our own. There might be better solutions by now, and it's not a 100% native
> solution (uses jQuery UI, and a JSON action), but we keep using it a lot in
> our application for various use-cases, and it's been a huge help.
>
> Check out the screenshot and the explanation over here:
> http://www.small-improvements.com/blog/technical/wicket-autocomplete-component
>
> It requires some work to adapt, but it may be worth it, depending on your
> usecase.
>
> Cheers,
> Per
>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/AutocompleteTextField-and-object-not-just-String-tp4650911p4651026.html
> Sent from the Users forum 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
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: AutocompleteTextField and object (not just String)
Posted by Per <pe...@hamburg.de>.
Hi Daniele,
while I don't have the answer to your question, here's a recent blogpost
about how we implemented a reusable wicket autocomplete field. We were not
entirely satisfied by the solutions we found about a year ago, so we cooked
our own. There might be better solutions by now, and it's not a 100% native
solution (uses jQuery UI, and a JSON action), but we keep using it a lot in
our application for various use-cases, and it's been a huge help.
Check out the screenshot and the explanation over here:
http://www.small-improvements.com/blog/technical/wicket-autocomplete-component
It requires some work to adapt, but it may be worth it, depending on your
usecase.
Cheers,
Per
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/AutocompleteTextField-and-object-not-just-String-tp4650911p4651026.html
Sent from the Users forum 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