java - Wicket - AjaxFormComponentUpdatingBehavior and backspace -


After

I get a TextField where I have added a AjaxFormComponentUpdatingBehavior Is for . Current value when user types some string

  filterByObject = new TextField & LT; String & gt; ("FilterByObject", true, new PropertyModel & lt; string & gt; (searchParams, "objectFilter"); AjaxFormComponentUpdatingBehavior changeFilterBinded = new AjaxFormComponentUpdatingBehavior ("onkeyup") {@Override zero onUpdate (AjaxRequestTarget target) {target.addComponent (componentToUpdate) remains secure; }}; FilterByObject.add (changeFilterBinded);   

When I put some letters inside the textfield , the onUpdate method is correctly called and the Search , changes correctly, unfortunately when I have used Backspace which I have inserted, then onUpdate is not called .

I change the event ( onkeypress , onkeydown , onchange etc ...) but it does not work. Only the on change works, but I have to change the focus to another component.

How can I save the day?

Is input incorrect in this area ( setRequired or IValidator s is added to the field) pressing the backspace key? If it is, the method will be known by name instead of onUpdate , because the user input will be invalid and therefore the module with the AjaxFormComponentUpdatingBehavior will not access the ModelObject. AjaxFormComponentUpdatingBehavior changeFilterBinded = New AjaxFormComponentUpdatingBehavior ("onkeyup") {@Override Zero onUpdate (AjaxRequestTarget Goal) {// Here the model object of the component has already been updated to target.addComponent (componentToUpdate) Remains safe; } @ Override Protected Zero Error (AjaxRequestTarget Goal, RuntimeException E) {// Here the component object of the component will remain unchanged, // so that it does not contain invalid input;};

Remember that any IFormValidator will not be included with the AJAX-IAEAD component, so you manually input before updating the model object May be interested in investigating. This is the case that you can ask to not update the model object automatically by overriding the AjaxFormComponentBehavior . After this, in the onUpdate method, getConvertedInput () . Get new input of component through

As a side note, onkeyup should be removed at least when pressing backspace key, and Onchange is usually a & lt; Input type = "text" & gt; ,

In addition, the HTML5 code introduces oninput event handler, which will be better suited to your needs. Removing / pasting in text fields will also be removed See the following link for more information:

Comments