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 6755135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:21:51+00:00 2026-05-26T13:21:51+00:00

I have an f:ajax tag inside an h:inputText tag, making ajax calls on keyup

  • 0

I have an f:ajax tag inside an h:inputText tag, making ajax calls on keyup events :

<h:inputText id="searchinput" value="#{tvShowForm.name}">
  <f:ajax event="keyup" render="results" listener="#{tvShowForm.search}" />
</h:inputText>

Each call takes enough time that the user has typed several characters before the first call is finished.

Is there a way to cancel the current ajax call (and the queued up ones), so that the last keyup event executes an ajax call immediately?

  • 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-05-26T13:21:51+00:00Added an answer on May 26, 2026 at 1:21 pm

    It sounds like you want to coalesce the events, for example this will wait
    half a second before firing an ajax request, and any input typed at that
    point will be included. But you won’t fire an ajax request for each character
    typed.

        <h:inputText onkeyup="keyupHandler();"/>
        ...
        <script>
        var keystrokeTimeout;
    
        keyupHandler = function(event) {
    
            var minChars = 4;
            var len = $(this).val().length;
            if((len != 0) && (len < minChars)) {
                return;
            }
    
            var ajaxRequest = function() {
                jsf.ajax.request('results', null, {
                    execute: 'results',
                    render: 'results'
                });
            }
            clearTimeout(keystrokeTimeout);
            keystrokeTimeout = setTimeout(ajaxRequest, 500); // millisecs
        }
        </script>
    

    Is this remotely like what you want to do?

    EDIT: Another suggestion is that you check out the Richfaces 4 a4j:queue functionality.
    This allows for combining events, for example in the keyup scenario if you’ve been
    leaning on your keyboard, when the current ajax request completes only one further
    request will be sent. It’s also possible to specify a request delay and ignore stale
    responses. The big mistake Richfaces doesn’t make (that primefaces does make) is that
    RF uses the same underlying queue as the JSF implementation, so you don’t have the risk
    of out-of-order processing.

    I appreciate that if you’re not already using this library it’s not a small step to take.

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

Sidebar

Related Questions

I have problem firing an ajax request with Primefaces <f:metadata> <f:viewParam name=token value=#{clientBean.token}/> <f:event
I have an Ajax request that can return more than one valid value, so
I have an ajax function that responds with contents of an html tag, as
I have forms inside a cakephp app that load through ajax. These forms have
I have an ajax execute-tag embedded in a commandLink-Tag in my JSF-File, which works
Inside of an asp.net mvc partial view, I have an Ajax form that posts
I have a Repeater with an ASP.NET AJAX 1.0 UpdatePanel inside it. There are
I would like to have Ajax form in Rails so i'm using form_remote_tag. The
I have ajax code for asp.net (non-mvc) to call to a webMethod to get
I have ajax request that do 3 missions: Save Model (DB) Send Email Give

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.