2 Replies Latest reply on Jan 22, 2010 9:51 AM by lvdberg

    EventsQueue and Concurrent call to conversation

      Hi all,
      I'm dealing with a concurrent call to conversation error. This happens when I click many times on a submit button. I tried to overcome this problem by using a a4j:queue, but I didn't get the expected result: I still have this kind of error.
      This is a portion of my xhtml code:




           <ui:define name="body">
      
                <s:div id="page" style="width:1400px">
                     
                     <h:form>
                               <a:queue id="mainQueue"/>
                                    
                          <div class="person-col"><rich:panel styleClass="mini-panel informazioni">
                               <f:facet name="header">
                               Informazioni anagrafiche 
                               </f:facet>
      
                               <a:region id="anagrafica">
      
                                    <s:decorate id="firstNameField" template="layout/edit.xhtml">
                                         <ui:define name="label">Nome</ui:define>
                                         <h:inputText id="firstName" required="true" size="38"
                                              maxlength="50" value="#{personHome.instance.firstName}"
                                              converter="#{upperCaseConverter}"
                                              style="text-transform:uppercase">
                                              <a:support event="onblur" reRender="firstNameField"
                                                   bypassUpdates="true" ajaxSingle="true" eventsQueue="mainQueue"/>
                                         </h:inputText>
                                    </s:decorate>
      


      ....



                          <s:div styleClass="button-div">
                               <h:commandLink id="save" value="Salva"
                                    action="#{personHome.persist}" styleClass="green left"  >
                                         <f:param name="comeBack" value="#{personHome.comeBack}">
                                         <a:support event="onclick" eventsQueue="mainQueue"/>
                                    </f:param>
                               </h:commandLink>




      Am I doing something wrong?


      Thanks in advance,


      Fabio



        • 1. Re: EventsQueue and Concurrent call to conversation
          niox.nikospara.yahoo.com

          Hello,


          I do not know how to enforce the correct behaviour to the server, but I suggest some client-side action.


          1) Something like:


          <a:commandLink ... onclick="return ajaxStarted(this)" oncomplete="ajaxEnded(this)" />
          



          Where: ajaxStarted() checks if an AJAX request is active on this link, and returns false if there is (so no second request is issued).


          ajaxEnded() marks that no AJAX request is active on this link, so any further may be issued again. If you used a button instead of link, JS-disabling it would also provide a visual cue to the user.


          A simplistic implementation with jQuery using the CSS class to mark AJAX activity:


          function ajaxStarted(x) {
               x = jQuery(x);
               if( x.hasClass("ajax") ) {
                    // AJAX request active, stop processing
                    return false;
               }
               else {
                    // mark AJAX activity
                    x.addClass("ajax");
                    return true;
               }
          }
          
          function ajaxEnded(x) {
               jQuery(x).removeClass("ajax");
          }
          



          2) Use an AJAX indicator to notify the user of AJAX activity. You could achieve this with the ajax CSS class above, or with some additions to ajaxStarted(), ajaxEnded(). Richfaces has an AJAX indicator component, which I don't like; why bother the server with pure client-side stuff?

          • 2. Re: EventsQueue and Concurrent call to conversation
            lvdberg

            Hi,


            this not really  a Seam question/problem, but has to do with configuring correctly the queue and the buttons. Most of them are nicely explained in the documentation under chapter 7.12, there you can see how to configure the stuuf to prevent these errors. You should basically throw-away all new request, while the old one is not yet processed.


            When you use and configure ajax-4-JSF correctly there is really no need to use additional clinet side scripyomg.


            Leo