One idea I had was to do something like the following code:

This class would be added to the AutocompleteTextField (as below).

inputSoFar would be the input to the getChoices() method minus the string we
are looking for, so for example:   

    fred,jim,b

inputSoFar would be 'fred,jim'. input (to getChoices( String input )) would
be 'b' after chopping off "fred,jim," - once the user selects 'bob' from the
autocompleter, then input would be 'bob' also.

So finally in the ChangeBehavor class, inputSoFar + input would resolve to
"fred,jim,bob" and be populated in the text field. 

Two problems with this:

a) It seems a bit hokey.
b) I have to store inputSoFar as a private member variable in the
AutocompleteTextField, which seems like an overhead to me.

Anyone got any thoughts?

Many thanks, Graeme.

    public class ChangeBehavior extends AjaxFormComponentUpdatingBehavior 
    {
        private static final long serialVersionUID = 8090648380154153004L;
        
        public ChangeBehavior()
        {
            super( "onchange" );
        }

        /* (non-Javadoc)
         * @see
org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior#onUpdate(org.apache.wicket.ajax.AjaxRequestTarget)
         */
        @Override
        protected void onUpdate( AjaxRequestTarget target )
        {
            String input = String.class.cast( getModelObject() );
            
            setModel( new Model( inputSoFar + input ) );
            
            target.addComponent( AutoCompleteContactTextField.this );
        }        
    }



Graeme Knight wrote:
> 
> Hi there!
> 
> Something like that - but I was hoping it might be easy to somehow do this
> with autocompletetextfield from wicket extensions - I guess there may be a
> little trickery to manipulating the unsubmitted text in the textfield
> itself (although this comes in as the input for getChoice so I was
> wondering if it were somehow useable from that).
> 
> 
> francisco treacy-2 wrote:
>> 
>> if i understand correctly you need a "multi" autocompleter.
>> 
>> do you mean something like this?
>> http://digitarald.de/project/autocompleter/1-1/showcase/delicious-tags/
>> (i have integrated it with wicket, it's indeed used when you edit
>> topics of a module in wickethub).
>> 
>> francisco
>> 
>> 
>> On Mon, Dec 15, 2008 at 8:36 PM, Graeme Knight <graeme1...@gmail.com>
>> wrote:
>>>
>>> Hi.
>>>
>>> Couldn't find an answer but perhaps this is a common thing to want to
>>> do:
>>>
>>> Using an AutoCompleteTextField I want to allow the user to select
>>> choices as
>>> he types, then update the text area by appending the selected choice.
>>> Similar to the way a web mail application would allow a user to type
>>> email
>>> address after email address and see them appended to the text field.
>>>
>>> Is there an easy way to achieve this?
>>>
>>> Many thanks, Graeme.
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Autocomplete-text-concatenation-tp21020322p21020322.html
>>> Sent from the Wicket - User 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
>> 
>> 
>> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Autocomplete-text-concatenation-tp21020322p21021857.html
Sent from the Wicket - User 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

Reply via email to