2 Replies Latest reply on Mar 25, 2010 2:21 PM by prather

    a4j:queue and a4j:jsFunction: ignoreDupResponses

    prather

      Using RichFaces 3.3.1.GA

       

      I have an a4j:commandButton with no action events wired up. It contains a s:defaultAction tag.  The only wire event on the commandButton is the onclick event which calls some javascript and the jsFunction. I also have a queue. Both are in an a4j:form.

      When a user types a value in the textbox and hits Enter, the onclick event fires, does a little javascript and calls the jsFunction. The jsFunction takes a value from a textbox and sends the value to my action bean.

       

      So, the queue keeps everything lined up nicely, except if values are Entered to quickly. It seems the queue thinks the request are similar and is combining/dropping some of them even though the values are different. I added a a4j:log to debug and it get the following:

       

      debug[16:56:47,522]: parameter  frmMain:jsExecuteSearch with value frmMain:jsExecuteSearch
      debug[16:56:47,522]: parameter param1  with value CAR
      debug[16:56:47,522]: Look up queue  with default name
      debug[16:56:47,522]: Found form queue  'frmMain'
      debug[16:56:47,522]: Similar request  currently in queue 'frmMain'
      debug[16:56:47,522]: Combine similar  requests and reset timer
      debug[16:56:47,522]: Queue will wait  0ms before submit

      .....

       

      debug[16:56:47,975]: parameter  frmMain:jsExecuteSearch with value frmMain:jsExecuteSearch
      debug[16:56:47,975]: parameter param1  with value TRUCK
      debug[16:56:47,975]: Look up queue  with default name
      debug[16:56:47,975]: Found form queue  'frmMain'
      debug[16:56:47,975]: Similar request  currently in queue 'frmMain'
      debug[16:56:47,975]: Combine similar  requests and reset timer
      debug[16:56:47,975]: Queue will wait  0ms before submit
      I tried adding ignoreDupResponses="false" but it seems to make no difference.
      Any help would be appreciated!
      Thanks,
      Prather
        • 1. Re: a4j:queue and a4j:jsFunction: ignoreDupResponses
          ilya_shaikovsky

          please post the code you using. I'm not sure that completelly get the case. in first part of the post you talking about the button and the jsFunction which it calls. And the problem later described as "occurs if typing fast".

          • 2. Re: a4j:queue and a4j:jsFunction: ignoreDupResponses
            prather

            A user types a number into the inputText box and hits enter. The onclick event of commandbutton fires a JavaScript function. The function moves the value from the inputText to a hidden textArea. Then the jsFunction is called which invokes the action bean method.

             

             

            <a4j:form id="frmMain" ajaxSubmit="true" ignoreDupResponses="false" >
                 <a4j:queue size="-1" requestDelay="0" ignoreDupResponses="false" />     
                 
                 <script type="text/javascript" >
            //<![CDATA[
            function resetTextBox(txtSearch, hdnSearch){
            var searchBox = document.getElementById(txtSearch);
            var searchValue = searchBox.value;
             
            searchBox.value = "";
            searchBox.focus();
             
            if(searchValue.length > 0){
            executeSearch(searchValue);
            return false;
            //return false regardless, just so that it will alternate 
                //a4j:jsFunction and a4j:commandButton requests thus
                //the a4j:queue wont think 2 request are similar.
            } else {
            return false;
            }
            }
            //]]>
                  </script>
             
             
            Serial# or MAC: <h:inputText id="txtSearch" maxlength="32" />
            <!-- for command button, not using the javascript return value because queue is grouping/dropping requests -->
             
            <a4j:commandButton id="btnSend" 
            value="Search"
            onclick="resetTextBox('frmMain:txtSearch', 'frmMain:hdnSearchValue');"
            disabled="#{equipmentTrackerItems.size ge 200}"
            ajaxSingle="true" 
            immediate="true" 
            bypassUpdates="true">
            <s:defaultAction />
            </a4j:commandButton>
             
             
            <a4j:jsFunction id="jsExecuteSearch" name="executeSearch" 
            action="#{equipmentTracker.search}" 
            status="statusSearching"
            ignoreDupResponses="false" 
            immediate="true" 
            requestDelay="0" 
            reRender="dgEquipment, divMaxCountSound">
            <a4j:actionparam name="param1" assignTo="#{equipmentTrackerSearchValue}" />
            </a4j:jsFunction>
             
             
            <h:inputTextarea id="txtHdnClipboardContents" 
            value="#{equipmentTracker.clipboardContents}" 
            style="display:none;" /> 
             
            <a4j:status id="statusSearching" startText="Processing...please wait" startStyle="color: #E96055; font: italic 900 14px sans-serif;" />
            ....
            </a4j:form>