2 Replies Latest reply on May 11, 2010 3:34 PM by Ben Maisano

    rich:suggestionbox in flight request causing issues

    Ben Maisano Newbie


           I have a weird issue and I believe I've narrowed it down to in-flight ajax request started from rich:suggestionbox.  I'm developing on Websphere, JSF RI 1.2, RichFaces 3.3.2, and Facelets 1.1.15.  I have a situation where the user wants an input box that has a suggestionbox attached but may also can just add a * wildcard character during their input and hit "enter" resulting in a full form post submission (regular commandButton).  If the user is not that fast, everything works fine, however if they are quick I have rendering problems.  It seems if they are typing and the rich:suggestionbox is hitting the db on each key stroke after minChars=2 and they hit enter before results of last request are back, the main dataTable rendered below does now have the proper, if any, rowIndex set.  I bind an HTMLDataTable element in my xhtml and generally it works fine, but if full post submitted before ajax request is back rowIndex coming as -1 or blank.  This then creates an error when they click link in dataTable.  Some xhtml tag snipplets below.  Any idea on this?  Is this a common problem with JSF and concurrent request?  I would think this may be a general issue with ajax calls and JSF and probably not specific to the rich:suggestionbox.  Any ideas or parameters I can use to control this or queue things up?  Any response is greatly appreciated, thank you.



      <rich:suggestionbox id="suggestionBoxCustomerName" for="customerNameInput"
                                                   suggestionAction="#{accountsMB.autoCompleteCustomerName}" var="result"
                                                minChars="2" nothingLabel="No customer names found" >
                                                       <h:outputText value="#{result}" />



      <h:dataTable id="accountResultsDataTable" value="#{accountsMB.accountRowPageBeans}"


           var="accountRow" rendered="#{accountsMB.haveResults == 'true'}" styleClass="dataTable"

           headerClass="dataTableHeader" first="0" rows="#{accountsMB.accountSearch.rowsPerPage}"

           rowClasses="dataTableRow, dataTableRowColor" style="float: left;">


                <f:facet name="header">

                <h:commandLink action="#{accountsMB.doSortByAccountName}"  > 

                <h:outputText value="Account" style="text-decoration: underline;"/>

                <h:outputText value="^" style="text-decoration: none;"

                     rendered="#{accountsMB.accountSearch.accountNameSort == true and accountsMB.accountSearch.sortOrder == 'ASC'}" />

                <h:outputText value="v" styleClass="sortOrderIndicator"

                     rendered="#{accountsMB.accountSearch.accountNameSort == true and accountsMB.accountSearch.sortOrder == 'DESC'}" />



           <h:commandLink action="#{accountsMB.doSelectAccountRow}" > 

                <h:outputText value="#{accountRow.accountNo} - #{accountRow.accountName}" />

                <f:param name="selectedIndexRow" value="#{accountsMB.accountRowIndex}" /> 




        • 1. Re: rich:suggestionbox in flight request causing issues
          Ilya Shaikovsky Master

          1) binding the component to the bean which has scope longer than request - will cause much problems in JSF (even without RichFaces) and one kind of problems could be caused to concurrent request and accessing the component instance from different concurrent requests.


          2) in order to avoid problems with frequent events and numerous ajax requests caused by them - use RichFaces Ajax queuing mechanism. Check a4j:queue documentation and see demo. (also pay attention to ajax optimization attributes like requestDelay, ignoreDupResponse and so on )

          1 of 1 people found this helpful
          • 2. Re: rich:suggestionbox in flight request causing issues
            Ben Maisano Newbie

            Thank you for the response Ilya, I understand your point and am adding the queue and optimization attributes to all my ajax components.  I do not understand your point on only request scope beans.  I am using session scope beans for mostly everything as we must for other business requirements.  I suppose I could have seperate request beans just for these ajax operations but I don't see the difference, could you explain or point me to the explanation?


            Also on the queuing mechanism, this is for serializing all ajax requests, were my issue here is actually concurrency between an ajax request and a regular commandButton's form post (full page refresh).  On the server side I think the ajax request is still running when full post happens.  Is there anything to deal with this?  Does JSF support concurrent requests?  I know browsers have different levels of support for concurrent connections but think most are at least 2 open/active.  Any thoughts on this are appreciated, thank you.