The onchange event is onchange only when focus is removed from the component. (This is the universal version of browser / javascript.)
Instead, you need to bind the handler to the onkeypress event.
You need not AjaxEventBehavior , but AjaxFormComponentUpdatingBehavior :
add( new AjaxFormComponentUpdatingBehavior( "onchange") { @Override protected void onUpdate(AjaxRequestTarget target) { System.out.println( "Value: "+field.getValue() ); } });
Although it works with getInput() well, usually a slightly higher level (properly shielded and supported by the model) getValue() better suited.
biziclop
source share