Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8203355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T07:31:28+00:00 2026-06-07T07:31:28+00:00

I have a TextField where I have added an AjaxFormComponentUpdatingBehavior to get the current

  • 0

I have a TextField where I have added an AjaxFormComponentUpdatingBehavior to get the current value when user write some string.

filterByObject = new TextField<String>("filterByObject", true, new PropertyModel<String>(searchParams, "objectFilter"));
AjaxFormComponentUpdatingBehavior  changeFilterBinded = new AjaxFormComponentUpdatingBehavior ("onkeyup") {
    @Override
    protected void onUpdate(AjaxRequestTarget target) {                         
        target.addComponent(componentToUpdate);
    }
};
filterByObject.add(changeFilterBinded);

When I put some chars inside textfield, onUpdate method is correctly called and my component, based on the current state of searchParams, changes correctly.
Unfortunally when I use Backspace to cancel what I have inserted, the onUpdate is not called.

I tried changing event (onkeypress, onkeydown, onchange etc…) but it doesn’t work. Only onChange works but I have to change focus to another component.

How can I save the day?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T07:31:29+00:00Added an answer on June 7, 2026 at 7:31 am

    Is the input in the field invalid (according to setRequired or IValidators added to the field) as a result of pressing the backspace key? If it is, the onError method will be called instead of onUpdate, because user input will be invalid and therefore will not reach the ModelObject of the component with the AjaxFormComponentUpdatingBehavior.

    AjaxFormComponentUpdatingBehavior  changeFilterBinded = 
      new AjaxFormComponentUpdatingBehavior ("onkeyup") {
        @Override
        protected void onUpdate(AjaxRequestTarget target) {     
            // Here the Component's model object has already been updated
            target.addComponent(componentToUpdate);
        }
        @Override
        protected void onError(AjaxRequestTarget target, RuntimeException e){
             // Here the Component's model object will remain unchanged, 
             // so that it doesn't hold invalid input
        }
    };
    

    Remember that any IFormValidator involving the ajax-ified component will not execute automatically, so you might be interested in checking the input for yourself manually before updating model objects if it’s the case. You can tell AjaxFormComponentBehavior not to update model objects automatically by overriding getUpdateModel(). Then, in the onUpdate method, get the component’s new input by means of getConvertedInput().

    As a side note, onkeyup should be getting fired when pressing the backspace key. At least it does in this fiddle, and onchange is generally triggered on an <input type="text"> when focusing out of it.

    Also, HTML5 introduces the oninput event handler, which may better suit your needs. It will get fired even when copying/pasting in the text field. See the following link for more information: Using the oninput event handler with onkeyup/onkeydown as its fallback.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have added a TextField to a UICell in order to allow a user
I have a textfield where the user can type what ever he want into
I have two text fields. In the first textfield I have added a calendar
I have a Jwindow, and when I added a Jtextfield to it, the textfield
I have added the following code for displaying a scrollbar to my textfield. But
I have a UITextField added to an UIAlerView (Kind of adding user to list
ok, here is the story... I have 3 textfield for user to select.... [textfield
I have set the delegate of my textfield to self and I have added
Hihi all, I have a TextField (the TextField is added into the TableViewCell from
I have a textfield that i want to hide when the user presses the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.