You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Chris <ch...@gmx.at> on 2015/05/19 16:32:10 UTC

AutoCompleteTextField

Hi all,

can the auto complete text field also be used in that way that it autocompletes words in the middle, too? 
Such as „minster“ for „Westminster Abbey“? In the example below only autocompletion for comparison of text start is demonstrated.

http://www.wicket-library.com/wicket-examples-6.0.x/ajax/autocomplete?1 <http://www.wicket-library.com/wicket-examples-6.0.x/ajax/autocomplete?1>

Thanks, Chris

Re: AutoCompleteTextField

Posted by Martin Grigorov <mg...@apache.org>.
https://github.com/apache/wicket/blob/31f3acb0d01af7be11a85c8e611c420180f77924/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/AutoCompletePage.java#L97

replace #startsWith() with #contains()

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Tue, May 19, 2015 at 5:32 PM, Chris <ch...@gmx.at> wrote:

> Hi all,
>
> can the auto complete text field also be used in that way that it
> autocompletes words in the middle, too?
> Such as „minster“ for „Westminster Abbey“? In the example below only
> autocompletion for comparison of text start is demonstrated.
>
> http://www.wicket-library.com/wicket-examples-6.0.x/ajax/autocomplete?1 <
> http://www.wicket-library.com/wicket-examples-6.0.x/ajax/autocomplete?1>
>
> Thanks, Chris

Re: AutoCompleteTextField

Posted by Chris <ch...@gmx.at>.
Hi Sven,

it works now - I have put the field into a form and override onSelected as well as added an AjaxFormSubmitBehaviour.

thanks, Chris


> Am 20.05.2015 um 09:22 schrieb Sven Meier <sv...@meiers.net>:
> 
> Hi Chris,
> 
> AutoCompleteTextField writes the text into its model as any normal textField:
> Either when the form is submitted, or - if you added an FormComponentUpdatingBehavior("change") - when the user leaves the input field.
> 
> Regards
> Sven
> 
> 
> On 19.05.2015 23:47, Chris wrote:
>> HI Sven,
>> 
>> how is it possible to get the input from the text field when the user does not select one value from the listed choices, but type in some text? I would also like to get this value, but currently the model does not get updated in this case.
>> 
>> Thanks, Chris
>> 
>> 
>>> Am 19.05.2015 um 16:36 schrieb Sven Meier <sv...@meiers.net>:
>>> 
>>> Sure, just implement #getChoices() accordingly.
>>> 
>>> Have fun
>>> Sven
>>> 
>>> 
>>> On 19.05.2015 16:32, Chris wrote:
>>>> Hi all,
>>>> 
>>>> can the auto complete text field also be used in that way that it autocompletes words in the middle, too?
>>>> Such as „minster“ for „Westminster Abbey“? In the example below only autocompletion for comparison of text start is demonstrated.
>>>> 
>>>> http://www.wicket-library.com/wicket-examples-6.0.x/ajax/autocomplete?1 <http://www.wicket-library.com/wicket-examples-6.0.x/ajax/autocomplete?1>
>>>> 
>>>> Thanks, Chris
>>> 
>>> ---------------------------------------------------------------------
>>> 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
>> 
> 
> 
> ---------------------------------------------------------------------
> 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

Posted by Sven Meier <sv...@meiers.net>.
Hi Chris,

AutoCompleteTextField writes the text into its model as any normal 
textField:
Either when the form is submitted, or - if you added an 
FormComponentUpdatingBehavior("change") - when the user leaves the input 
field.

Regards
Sven


On 19.05.2015 23:47, Chris wrote:
> HI Sven,
>
> how is it possible to get the input from the text field when the user does not select one value from the listed choices, but type in some text? I would also like to get this value, but currently the model does not get updated in this case.
>
> Thanks, Chris
>
>
>> Am 19.05.2015 um 16:36 schrieb Sven Meier <sv...@meiers.net>:
>>
>> Sure, just implement #getChoices() accordingly.
>>
>> Have fun
>> Sven
>>
>>
>> On 19.05.2015 16:32, Chris wrote:
>>> Hi all,
>>>
>>> can the auto complete text field also be used in that way that it autocompletes words in the middle, too?
>>> Such as „minster“ for „Westminster Abbey“? In the example below only autocompletion for comparison of text start is demonstrated.
>>>
>>> http://www.wicket-library.com/wicket-examples-6.0.x/ajax/autocomplete?1 <http://www.wicket-library.com/wicket-examples-6.0.x/ajax/autocomplete?1>
>>>
>>> Thanks, Chris
>>
>> ---------------------------------------------------------------------
>> 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
>


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


Re: AutoCompleteTextField

Posted by Chris <ch...@gmx.at>.
HI Sven,

how is it possible to get the input from the text field when the user does not select one value from the listed choices, but type in some text? I would also like to get this value, but currently the model does not get updated in this case.

Thanks, Chris


> Am 19.05.2015 um 16:36 schrieb Sven Meier <sv...@meiers.net>:
> 
> Sure, just implement #getChoices() accordingly.
> 
> Have fun
> Sven
> 
> 
> On 19.05.2015 16:32, Chris wrote:
>> Hi all,
>> 
>> can the auto complete text field also be used in that way that it autocompletes words in the middle, too?
>> Such as „minster“ for „Westminster Abbey“? In the example below only autocompletion for comparison of text start is demonstrated.
>> 
>> http://www.wicket-library.com/wicket-examples-6.0.x/ajax/autocomplete?1 <http://www.wicket-library.com/wicket-examples-6.0.x/ajax/autocomplete?1>
>> 
>> Thanks, Chris
> 
> 
> ---------------------------------------------------------------------
> 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

Posted by Sven Meier <sv...@meiers.net>.
Hi Chris,

let me guess:
Your panel passes its model to its child components.
If you change the panels model later on, the child components still 
refer to the original model.

Have fun
Sven


On 19.05.2015 23:37, Chris wrote:
> Hi Sven,
>
> it works when I set the object of the existing panel’s model but do not replace the model:
>
> existModel.setObject(new List…);
> panel.setDefaultModel(existModel)
>
> Why doesn’t it work when replacing the model at all?
> panel.setDefaultModel(newModel)
>
> br, Chris
>
>
>
>> Am 19.05.2015 um 23:11 schrieb Sven Meier <sv...@meiers.net>:
>>
>> Hi,
>>
>>> panel.setDefaultModel(searchModel);
>> does your panel pass its model to the repeater component?
>>
>> Regards
>> Sven
>>
>>
>> On 19.05.2015 23:04, Chris wrote:
>>> Hi,
>>>
>>> I have implemented the AutoComplete text field. Based on the input, I would like to change the model of a panel to show an updated list of elements.
>>> In the below code, the method #getObject of the searchModel never gets executed and the panel’s list is not refreshed.
>>>
>>> What might be missing?
>>>
>>> Thanks, Chris
>>>
>>>
>>> add(new AjaxFallbackLink("searchButton") {
>>>              @Override
>>>              public void onClick(AjaxRequestTarget target) {
>>>
>>>                  IModel<List<A>> searchModel = new ListModel<A>() {
>>>
>>>                      @Override
>>>                      public List<A> getObject() {
>>>
>>>                          List<A> list = Lists.newArrayList();
>>>                          Map<String, A> map = service.getObjects();
>>>                          for (String name : map.keySet()) {
>>>                                  list.add(map.get(name));
>>>                          }
>>>                          return list;
>>>                      }
>>>                  };
>>>
>>>
>>>                  panel.setDefaultModel(searchModel);
>>>                  panel.modelChanged();
>>> 		target.add(panel);
>>>
>>>                  send(getPage(), Broadcast.BREADTH, new ShowItem(target));
>>>
>>>              }
>>> });
>>>
>>>
>>>> Am 19.05.2015 um 16:36 schrieb Sven Meier <sv...@meiers.net>:
>>>>
>>>> Sure, just implement #getChoices() accordingly.
>>>>
>>>> Have fun
>>>> Sven
>>>>
>>>>
>>>> On 19.05.2015 16:32, Chris wrote:
>>>>> Hi all,
>>>>>
>>>>> can the auto complete text field also be used in that way that it autocompletes words in the middle, too?
>>>>> Such as „minster“ for „Westminster Abbey“? In the example below only autocompletion for comparison of text start is demonstrated.
>>>>>
>>>>> http://www.wicket-library.com/wicket-examples-6.0.x/ajax/autocomplete?1 <http://www.wicket-library.com/wicket-examples-6.0.x/ajax/autocomplete?1>
>>>>>
>>>>> Thanks, Chris
>>>> ---------------------------------------------------------------------
>>>> 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
>>>
>>
>> ---------------------------------------------------------------------
>> 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
>


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


Re: AutoCompleteTextField

Posted by Chris <ch...@gmx.at>.
Hi Sven,

it works when I set the object of the existing panel’s model but do not replace the model:

existModel.setObject(new List…);
panel.setDefaultModel(existModel)

Why doesn’t it work when replacing the model at all?
panel.setDefaultModel(newModel)

br, Chris



> Am 19.05.2015 um 23:11 schrieb Sven Meier <sv...@meiers.net>:
> 
> Hi,
> 
>> panel.setDefaultModel(searchModel);
> 
> does your panel pass its model to the repeater component?
> 
> Regards
> Sven
> 
> 
> On 19.05.2015 23:04, Chris wrote:
>> Hi,
>> 
>> I have implemented the AutoComplete text field. Based on the input, I would like to change the model of a panel to show an updated list of elements.
>> In the below code, the method #getObject of the searchModel never gets executed and the panel’s list is not refreshed.
>> 
>> What might be missing?
>> 
>> Thanks, Chris
>> 
>> 
>> add(new AjaxFallbackLink("searchButton") {
>>             @Override
>>             public void onClick(AjaxRequestTarget target) {
>> 
>>                 IModel<List<A>> searchModel = new ListModel<A>() {
>> 
>>                     @Override
>>                     public List<A> getObject() {
>> 
>>                         List<A> list = Lists.newArrayList();
>>                         Map<String, A> map = service.getObjects();
>>                         for (String name : map.keySet()) {
>>                                 list.add(map.get(name));
>>                         }
>>                         return list;
>>                     }
>>                 };
>> 
>> 
>>                 panel.setDefaultModel(searchModel);
>>                 panel.modelChanged();
>> 		target.add(panel);
>> 
>>                 send(getPage(), Broadcast.BREADTH, new ShowItem(target));
>> 
>>             }
>> });
>> 
>> 
>>> Am 19.05.2015 um 16:36 schrieb Sven Meier <sv...@meiers.net>:
>>> 
>>> Sure, just implement #getChoices() accordingly.
>>> 
>>> Have fun
>>> Sven
>>> 
>>> 
>>> On 19.05.2015 16:32, Chris wrote:
>>>> Hi all,
>>>> 
>>>> can the auto complete text field also be used in that way that it autocompletes words in the middle, too?
>>>> Such as „minster“ for „Westminster Abbey“? In the example below only autocompletion for comparison of text start is demonstrated.
>>>> 
>>>> http://www.wicket-library.com/wicket-examples-6.0.x/ajax/autocomplete?1 <http://www.wicket-library.com/wicket-examples-6.0.x/ajax/autocomplete?1>
>>>> 
>>>> Thanks, Chris
>>> 
>>> ---------------------------------------------------------------------
>>> 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
>> 
> 
> 
> ---------------------------------------------------------------------
> 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

Posted by Sven Meier <sv...@meiers.net>.
Hi,

> panel.setDefaultModel(searchModel);

does your panel pass its model to the repeater component?

Regards
Sven


On 19.05.2015 23:04, Chris wrote:
> Hi,
>
> I have implemented the AutoComplete text field. Based on the input, I would like to change the model of a panel to show an updated list of elements.
> In the below code, the method #getObject of the searchModel never gets executed and the panel’s list is not refreshed.
>
> What might be missing?
>
> Thanks, Chris
>
>
> add(new AjaxFallbackLink("searchButton") {
>              @Override
>              public void onClick(AjaxRequestTarget target) {
>
>                  IModel<List<A>> searchModel = new ListModel<A>() {
>
>                      @Override
>                      public List<A> getObject() {
>
>                          List<A> list = Lists.newArrayList();
>                          Map<String, A> map = service.getObjects();
>                          for (String name : map.keySet()) {
>                                  list.add(map.get(name));
>                          }
>                          return list;
>                      }
>                  };
>
>
>                  panel.setDefaultModel(searchModel);
>                  panel.modelChanged();
> 		target.add(panel);
>
>                  send(getPage(), Broadcast.BREADTH, new ShowItem(target));
>
>              }
> });
>
>
>> Am 19.05.2015 um 16:36 schrieb Sven Meier <sv...@meiers.net>:
>>
>> Sure, just implement #getChoices() accordingly.
>>
>> Have fun
>> Sven
>>
>>
>> On 19.05.2015 16:32, Chris wrote:
>>> Hi all,
>>>
>>> can the auto complete text field also be used in that way that it autocompletes words in the middle, too?
>>> Such as „minster“ for „Westminster Abbey“? In the example below only autocompletion for comparison of text start is demonstrated.
>>>
>>> http://www.wicket-library.com/wicket-examples-6.0.x/ajax/autocomplete?1 <http://www.wicket-library.com/wicket-examples-6.0.x/ajax/autocomplete?1>
>>>
>>> Thanks, Chris
>>
>> ---------------------------------------------------------------------
>> 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
>


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


Re: AutoCompleteTextField

Posted by Chris <ch...@gmx.at>.
Hi, 

I have implemented the AutoComplete text field. Based on the input, I would like to change the model of a panel to show an updated list of elements.
In the below code, the method #getObject of the searchModel never gets executed and the panel’s list is not refreshed.

What might be missing?

Thanks, Chris


add(new AjaxFallbackLink("searchButton") {
            @Override
            public void onClick(AjaxRequestTarget target) {

                IModel<List<A>> searchModel = new ListModel<A>() {

                    @Override
                    public List<A> getObject() {

                        List<A> list = Lists.newArrayList();
                        Map<String, A> map = service.getObjects();
                        for (String name : map.keySet()) {
                                list.add(map.get(name));
                        }
                        return list;
                    }
                };


                panel.setDefaultModel(searchModel);
                panel.modelChanged();
		target.add(panel);

                send(getPage(), Broadcast.BREADTH, new ShowItem(target));

            }
});


> Am 19.05.2015 um 16:36 schrieb Sven Meier <sv...@meiers.net>:
> 
> Sure, just implement #getChoices() accordingly.
> 
> Have fun
> Sven
> 
> 
> On 19.05.2015 16:32, Chris wrote:
>> Hi all,
>> 
>> can the auto complete text field also be used in that way that it autocompletes words in the middle, too?
>> Such as „minster“ for „Westminster Abbey“? In the example below only autocompletion for comparison of text start is demonstrated.
>> 
>> http://www.wicket-library.com/wicket-examples-6.0.x/ajax/autocomplete?1 <http://www.wicket-library.com/wicket-examples-6.0.x/ajax/autocomplete?1>
>> 
>> Thanks, Chris
> 
> 
> ---------------------------------------------------------------------
> 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

Posted by Sven Meier <sv...@meiers.net>.
Sure, just implement #getChoices() accordingly.

Have fun
Sven


On 19.05.2015 16:32, Chris wrote:
> Hi all,
>
> can the auto complete text field also be used in that way that it autocompletes words in the middle, too?
> Such as „minster“ for „Westminster Abbey“? In the example below only autocompletion for comparison of text start is demonstrated.
>
> http://www.wicket-library.com/wicket-examples-6.0.x/ajax/autocomplete?1 <http://www.wicket-library.com/wicket-examples-6.0.x/ajax/autocomplete?1>
>
> Thanks, Chris


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