Hi Peter, Looking at the code I think you'll need to touch wicket-autocomplete.js. Copy it to your project and override org.apache.wicket.extensions.ajax.markup.html.autocomplete.AutoCompleteBehavior#renderHead(IHeaderResponse) so that it loads your .js file. Then make org.apache.wicket.extensions.ajax.markup.html.autocomplete.AutoCompleteTextField.newAutoCompleteBehavior(IAutoCompleteRenderer<T>, AutoCompleteSettings) return your custom AutoCompleteBehavior.
In the .js itself you'll need to touch "function setSelected(newSelected)" at line 212 (1.4-SNAPSHOT). Each time this function is called you'll have to make your Ajax call. Good luck! On Thu, Sep 9, 2010 at 1:07 PM, Peter Karich <peat...@yahoo.de> wrote: > Hi Pieter, > > thanks for your quick response! And sorry, I didn't mention that I am using > > org.apache.wicket.extensions.ajax.markup.html.autocomplete.AutoCompleteTextField > from wicket extensions. Or did you have another autocomplete component > in mind that I am not aware of? > > Nevertheless I tried the AjaxFormComponentUpdatingBehavior which has the > unwanted side effect that other values will be submitted too. > Then I tried with > autoCompleteField.add(new OnChangeAjaxBehavior() { > @Override > protected void onUpdate(AjaxRequestTarget target) { > // sout here > }); > > But this will fire only every time I change the textfield value, not the > selection of the suggestions :-( > > Regards, > Peter. > > > add AjaxFormComponentUpdatingBehavior to your dropdownChoice. > > > > new AjaxFormComponentUpdatingBehavior("onchange") { > > @Override > > protected void onUpdate(AjaxRequestTarget target) { > > //do the needed stuff here... > > } > > }) > > > > The onUpdate() will be triggered when the selection changes, however the > > behavor will be different if you do this with mous or keys (and even from > > browser to brower if I'm not mistaking....) > > Anyhow, with FireFow it is a follows: > > > > with mouse: onUpdate(..) is fired from the moment you change the > selection. > > with keys: onUpdate(..) is fired from the moment you change the selection > > AND the component loses focus (by pressing tab for example) or the user > > presses ENTER > > > > > > Hope this helps. > > > > > > Pieter > > > > On Thu, Sep 9, 2010 at 12:00 PM, Peter Karich <peat...@yahoo.de> wrote: > > > > > >> Hi, > >> > >> I would like to fire an ajax event every time the user changes the > >> selection of the choices > >> e.g. he switches from 'wiki' to 'wicket' with keys or mouse > >> > >> Which function is necessary to fire such an event on the client side? > >> I never did sth. similar to this and tried (without success + a long > >> time) to customize wicket-autocomplete.js according to some hints [1] . > >> And how can I add a behaviour on the server side which listens to this > >> custom event? Any hints? > >> > >> Regards, > >> Peter. > >> > >> [1] > >> > >> > http://day-to-day-stuff.blogspot.com/2006/10/wicket-autocompletion-improvements.html > >> > >> > http://karthikg.wordpress.com/2008/01/24/developing-a-custom-apache-wicket-component/ > >> > >> > http://ptrthomas.wordpress.com/2009/08/12/wicket-tutorial-yui-autocomplete-using-json-and-ajax/ > >> > >> --------------------------------------------------------------------- > >> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > >> For additional commands, e-mail: users-h...@wicket.apache.org > >> > >> > >> > > > > > > > -- > http://jetwick.com twitter search prototype > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > >