My AutoCompleteTextField (getChoices method implemented and working):
AutoCompleteTextField<String> objectDescription = new AutoCompleteTextField<String>("objectDescription") {
getChoices() {...}
}
To this textfield I add:
objectDescription.add(new OnChangeAjaxBehavior()) {
onUpdate() {....}
}
The onUpdate method gets called everytime I write something in my textfield but not when I choose some item from the autocomplete menu. The string from the menu is written to the textfield but only calls the onUpdate when another change is made.
Edit: Before Wicket 1.5 this was working.
Add an
AjaxFormComponentUpdatingBehavior("onchange").The
OnChangeAjaxbehavior()seems to fire at every change (uses the JavascriptWicket.ChangeHandler), like in every key press.Using an
AjaxFormComponentUpdatingBehaviorwill add the event listener toonChangejavascript events, like in focusing out of the textfield with a different value, or in selecting a value from the autocomplete list.Still not sure why doesn’t
OnChangeAjaxbehavior extends AjaxFormComponentUpdatingBehaviorinherit this logic fromAjaxFormComponentUpdatingBehavior, there must be something it’s overriding.UPDATE This might well be the reason why
onchangejavascript events are being ignored when usingOnChangeAjaxBehavior. The source code forWicket.ChangeHandler, found in wicket-ajax.js, sets handlers for different events:onchangeevent handler inonchangeoriginal:onchangeevent handler toonKeyUp,onpasteandoncut.onchangeevent handler toonInput.Finally, it always removes the
onchangeevent handler:The code in
wicket-autocomplete.jsseems to be manually firing theonchangeevent handler at item selection. Probably it should be checking forobj.onchangeoriginalfirst.So, being this js executed in
OnDomReady, I doubt it’s possible to make those two behaviors coexist. Maybe it’s time to file a new JIRA?This might be a slightly related issue: WICKET-2424: OnChangeAjaxBehavior + DatePicker do not work together