Re: AutocompleteTextField and object (not just String)

2012-08-06 Thread Igor Vaynberg
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  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-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>

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



Re: AutocompleteTextField and object (not just String)

2012-08-06 Thread Per
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-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: AutocompleteTextField and object (not just String)

2012-08-01 Thread Sven Meier
As Igor has written, AutoCompleteTextField is a TextField and thus depends on 
converters.

I'll improve the javadoc.

Sven

Martin Grigorov  schrieb:

>Hey Sven,
>
>On Wed, Aug 1, 2012 at 2:01 PM, Sven Meier  wrote:
>>> DropDown has a clear pattern:
>>> the renderer is used only for
>>> rendering purpose
>>
>> BTW this is not correct: all choice components use their renderer for 
>> rendering AND input, AutoCompleteTextField uses its renderer for rendering 
>> only.
>
>Do you know why this is the case ?
>Is it possible to improve ACTF to be smarter ?
>
>>
>> Sven
>>
>> Sven Meier  schrieb:
>>
>>>You have to overwrite AutoCompleteTextfield#getConverter() and provide a 
>>>converter for your object.
>>>
>>>You can use #getChoices() to find the correct object for the new input.
>>>
>>>Sven
>>>
>>>Daniele Dellafiore  schrieb:
>>>
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("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 Dell
>> -
>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
>> For additional commands, e-mail: users-h...@wicket.apache.org
>>
>
>
>
>-- 
>Martin Grigorov
>jWeekend
>Training, Consulting, Development
>http://jWeekend.com
>
>-
>To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
>For additional commands, e-mail: users-h...@wicket.apache.org
>


Re: AutocompleteTextField and object (not just String)

2012-08-01 Thread Igor Vaynberg
On Wed, Aug 1, 2012 at 4:08 AM, Martin Grigorov  wrote:
> Hey Sven,
>
> On Wed, Aug 1, 2012 at 2:01 PM, Sven Meier  wrote:
>>> DropDown has a clear pattern:
>>> the renderer is used only for
>>> rendering purpose
>>
>> BTW this is not correct: all choice components use their renderer for 
>> rendering AND input, AutoCompleteTextField uses its renderer for rendering 
>> only.
>
> Do you know why this is the case ?

because autocomplete is *not* a choice component. you can pick a value
that is not in the choices collection. that is why i created select2.
we had a bunch of autocompletes we were using to pick from existing
choices and it led to all kinds of headaches because it is not what
autocomplete is meant for.

-igor

> Is it possible to improve ACTF to be smarter ?
>
>>
>> Sven
>>
>> Sven Meier  schrieb:
>>
>>>You have to overwrite AutoCompleteTextfield#getConverter() and provide a 
>>>converter for your object.
>>>
>>>You can use #getChoices() to find the correct object for the new input.
>>>
>>>Sven
>>>
>>>Daniele Dellafiore  schrieb:
>>>
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("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 Dell
>> -
>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
>> For additional commands, e-mail: users-h...@wicket.apache.org
>>
>
>
>
> --
> Martin Grigorov
> jWeekend
> Training, Consulting, Development
> http://jWeekend.com
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>

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



Re: AutocompleteTextField and object (not just String)

2012-08-01 Thread Martin Grigorov
Hey Sven,

On Wed, Aug 1, 2012 at 2:01 PM, Sven Meier  wrote:
>> DropDown has a clear pattern:
>> the renderer is used only for
>> rendering purpose
>
> BTW this is not correct: all choice components use their renderer for 
> rendering AND input, AutoCompleteTextField uses its renderer for rendering 
> only.

Do you know why this is the case ?
Is it possible to improve ACTF to be smarter ?

>
> Sven
>
> Sven Meier  schrieb:
>
>>You have to overwrite AutoCompleteTextfield#getConverter() and provide a 
>>converter for your object.
>>
>>You can use #getChoices() to find the correct object for the new input.
>>
>>Sven
>>
>>Daniele Dellafiore  schrieb:
>>
>>>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("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 Dell
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

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



Re: AutocompleteTextField and object (not just String)

2012-08-01 Thread Sven Meier
> DropDown has a clear pattern: 
> the renderer is used only for
> rendering purpose

BTW this is not correct: all choice components use their renderer for rendering 
AND input, AutoCompleteTextField uses its renderer for rendering only.

Sven

Sven Meier  schrieb:

>You have to overwrite AutoCompleteTextfield#getConverter() and provide a 
>converter for your object.
>
>You can use #getChoices() to find the correct object for the new input.
>
>Sven
>
>Daniele Dellafiore  schrieb:
>
>>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("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 Dell
-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: AutocompleteTextField and object (not just String)

2012-08-01 Thread Sven Meier
You have to overwrite AutoCompleteTextfield#getConverter() and provide a 
converter for your object.

You can use #getChoices() to find the correct object for the new input.

Sven

Daniele Dellafiore  schrieb:

>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("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-unsubscr...@wicket.apache.org
>For additional commands, e-mail: users-h...@wicket.apache.org
>


Re: AutocompleteTextField and object (not just String)

2012-08-01 Thread Giovanni Cuccu

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("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-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



AutocompleteTextField and object (not just String)

2012-08-01 Thread Daniele Dellafiore
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("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-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org