Hi,

thanks for your answer.

No, solution didn't work as supposed, mainly because the AutoComplete fills
the input field in the browser with the data (in my case either zipcode or
city), but doesn't update the model.

To update the model I have to attach some Ajax...Behavior, but this is
called with the data put into the textfield (i.e. either the selected
zipcode put into the zipcode field by the autocomplete, *or* the selected
city from the city field). In the Ajax...Behavior's onUpdate()-method
neither the city nor the zipcode are enough to determine the value to use to
update the related field.

So I had two other ideas:

1. in my autocomplete-list I set the "textvalue" to the id of a
"zipcode-city" combination. When the user selects from the
autocomplete-list, this id is written into the corresponding input-field.
The attached AjaxOnChangeBehavior now gets this id, determines the
zipcode-city, and updates the city and the zipcode field. This works, but
looks a little strange to the user (e.g. selection of "71254 Ditzingen" from
autocomplete-list writes the id ("1223") into the zipcode-field, this issues
the Ajax-call, which updates both fields with the correct data, i.e.
zipcode=71254, city=Ditzingen). As I said, works but not pretty.

2. So I'm currently extended the AutoCompleteTextField, ...Renderer,
...Behavior, ..JavaScript to accept a second, "related" field in its
constructor. I then attach two attributes to the autocomplete-list entries
(say textvalue and textvalue2), and modified the JavaScript to update both
fields. This seems to me the best approach to my specific problem, and seems
to work as intended.

Hope my answer was not to confusing...
regards,
Oliver


German Morales wrote:
> 
> Hi,
> 
> Sorry, i'm a little late with my response.
> Did the suggestion by Nino work?
> 
> If it works, i would like to know more details about it.
> 
> If not, we already had a somehow similar problem (Swiss addresses), and we
> have a different solution already working. Perhaps it can help you too.
> 
> Regards,
> 
> German
> 
> 
> It seems that Nino Saturnino Martinez Vazquez Wael wrote:
>> NP, waiting with excitement to hear if it works:)
>>
>> Oliver Lieven wrote:
>>> Thanks allot for your efforts and detailed answer! Sounds good, I'll
>>> give it
>>> a try.
>>>
>>>
>>> Nino.Martinez wrote:
>>>
>>>> No what I meant was that when a user selects something in one  of your
>>>> auto complete fields  they'll automatickly select something in both,
>>>> might have been a little scares on information:
>>>>
>>>> IModel commonModel=new Model();
>>>>
>>>>
>>>> AbstractModel() Text=new AbstractModel(){
>>>>
>>>> getObject{
>>>>     return commonModel.getObject.Text;
>>>> }
>>>> setObject(obj){
>>>>     commonModel.setObject(obj)
>>>> }
>>>>
>>>> }
>>>>
>>>>
>>>> AbstractModel() name=new AbstractModel(){
>>>>
>>>> getObject{
>>>>     return commonModel.getObject.name;
>>>> }
>>>> setObject(obj){
>>>>     commonModel.setObject(obj)
>>>> }
>>>>
>>>> }
>>>>
>>>>
>>>>
>>>> AutoCompleteTextField phoneName = new AutoCompleteTextField(
>>>>                 "phoneName", name,
>>>>                 new BestEffortRendererAutoCompleteRenderer()) {
>>>>             @Override
>>>>             protected Iterator getChoices(String input) {
>>>>
>>>>                 return findItems(input);
>>>>             }
>>>>         };
>>>>
>>>>
>>>> AutoCompleteTextField phoneSeries = new AutoCompleteTextField(
>>>>                 "phoneName", text,
>>>>                 new BestEffortRendererAutoCompleteRenderer()) {
>>>>             @Override
>>>>             protected Iterator getChoices(String input) {
>>>>
>>>>                 return findItems(input);
>>>>             }
>>>>         };
>>>>
>>>> And ofcourse you need to add the other completefield to the
>>>> ajaxresponse...
>>>>
>>>> Hope this pseudo code works a little better... Was on my way out the
>>>> door before...
>>>>
>>>>
>>>> Oliver Lieven wrote:
>>>>
>>>>> Hi Nino,
>>>>> thanks for your fast reply. Yes, a shared PropertyModel would help to
>>>>> keep
>>>>> both fields synchronized.
>>>>>
>>>>> I still can't see how this could help me to determine the value
>>>>> selected
>>>>> by
>>>>> the user.
>>>>> The AutoComplete works like
>>>>>
>>>>> 1. getChoices() is called to populate the autocomplete list with my
>>>>> "zipcode
>>>>> - city" options
>>>>> 2. when user selects a value from the autocomplete list, the
>>>>> corresponding
>>>>> field is set with the "textvalue" (e.g. the 'city' field is filled
>>>>> with
>>>>> the
>>>>> city's name)
>>>>> 3. because of this update, the city-field's
>>>>> AjaxFormComponentUpdatingBehavior.onUpdate() is called
>>>>> 4. in onUpdate() the getConvertedInput() method returns the city name,
>>>>> which
>>>>> is insufficient to determine the corresponding zipcode (because of the
>>>>> n:1
>>>>> relation (city may have many zipcodes)).
>>>>>
>>>>> So I'm still looking for a way to determine the exact combination
>>>>> selected
>>>>> by the user...
>>>>>
>>>>> regards,
>>>>> Oliver
>>>>>
>>>>>
>>>>> Nino.Martinez wrote:
>>>>>
>>>>>
>>>>>> Quick answer, why not use property models and use both in the fiields
>>>>>> you mention?
>>>>>>
>>>>>> Oliver Lieven wrote:
>>>>>>
>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> in an address edit panel I've got the two AutoCompleteText fields
>>>>>>> 'zipcode'
>>>>>>> and 'city'.
>>>>>>>
>>>>>>> When a users begins typing into the zipcode-field, the autocomplete
>>>>>>> shows
>>>>>>> up
>>>>>>> and offers valid "zipcode - city" combinations. After selecting a
>>>>>>> value
>>>>>>> from
>>>>>>> the autocomplete the 'zipcode' is set. Same for 'city' field, i.e.
>>>>>>> after
>>>>>>> selecting a "zipcode - city" from the city's autocomplete the
>>>>>>> "city"-field
>>>>>>> is set accordingly.
>>>>>>> (Thanks for the great autocomplete-support in Wicket which allows
>>>>>>> separation
>>>>>>> of displayvalue and textvalue!)
>>>>>>>
>>>>>>> Now to my question: after selection of a "zipcode - city"
>>>>>>> combination
>>>>>>> from
>>>>>>> either autocomplete list I would like to set both fields (zipcode
>>>>>>> and
>>>>>>> city).
>>>>>>> I already attached an AjaxFormComponentUpdatingBehavior which gets
>>>>>>> called
>>>>>>> after a selection in the autocomplete list, but it just gets the
>>>>>>> zipcode/city currently set.
>>>>>>> Since the zipcode-city relation is 1:n (e.g. Berlin has many
>>>>>>> zipcodes)
>>>>>>> I'm
>>>>>>> wondering if there is a way to access the full selected value (and
>>>>>>> not
>>>>>>> only
>>>>>>> the AbstractAutoCompleteTextRenderer.textvalue set).
>>>>>>>
>>>>>>>
>>>>>>> Thanks for any help and tips!
>>>>>>> Oliver
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> 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]
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> 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]
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/AutoCompleteTextfield---how-to-populate-two-input-fields-tf4592192.html#a13158414
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to