Hi, You need to register the AjaxCallListener: attributes.getAjaxCallListeners().add(myAjaxCallListener)
Martin Grigorov Freelancer. Available for hire! Wicket Training and Consulting https://twitter.com/mtgrigorov On Thu, Jul 9, 2015 at 5:11 AM, gump lee <[email protected]> wrote: > Hello All, > > I am using Wicket 6.19. I added a > AjaxFormComponentUpdatingBehavior("keypress") > to a textfield so that when press any key will trigger my application to > update something. I want this only happen when user press 'Enter' key. so > that I override the method updateAjaxAttributes in the > AjaxFormComponentUpdatingBehavior > > @Override > protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { > super.updateAjaxAttributes(attributes); > AjaxCallListener myAjaxCallListener = new AjaxCallListener() { > @Override > public CharSequence getPrecondition(Component component) { > String script = "var keycode = Wicket.Event.keyCode(attrs.event);" > + "if (keycode == 13) {" > + " return true;" > + "} else {" + " return false;}"; > > return script; > } > }; > attributes.getAjaxCallListeners().add(myAjaxCallListener); > attributes.setEventPropagation(EventPropagation.STOP); > } > > However, after the ajax call, the form submit also triggered. Does anyone > know the correct way to stop this form submit? > > > Thanks and best regards, > Gump >
