7 Replies Latest reply on Nov 5, 2012 8:55 AM by jackielii

    Why is my jsfunction action only called once?

    jackielii

      Helo everyone,

       

      I have the following jsFunction

      {code:xml}<a:jsFunction name="saveEdit"

                action="#{bean.saveEdit()}"

                eventsQueue="queue_save"

                ignoreDupResponses="false"

                requestDelay="10">

                <a:actionparam name="data" assignTo="#{bean.data}" />

      </a:jsFunction>

      {code}

      and I'm calling it on one user input, e.g. user click on one button, and invoked:

      {code:xml}<javascript>saveEdit('a');saveEdit('b');saveEdit('c');</javascript>

      {code}

       

      I debuged my server side code, and found out it's only called once, only the first request is passed back to the server.

       

      why is this? I thought ignoreDupResponses is for setting this?

       


      Thanks for your help!

      Jackie

        • 1. Re: Why is my jsfunction action only called once?
          liuliu

          hi

          i think it is because you have created a queue.

          • 2. Re: Why is my jsfunction action only called once?
            jackielii

            Hello Hu,

             

            Thanks very much for your reply.

             

            I just tried removing that line but it's still the same. The action was just executed once.

             

             

            Regards,

            Jackie

            • 3. Re: Why is my jsfunction action only called once?
              liuliu

              your version de RF and JSF?

              • 4. Re: Why is my jsfunction action only called once?
                jackielii

                jsf-facelets-1.1.15.B1.jar

                richfaces-ui-3.3.1.GA.jar

                 

                is this what your are asking?

                 

                Thanks

                • 5. Re: Why is my jsfunction action only called once?
                  liuliu

                  have you removed requestDelay attribute too?

                  • 6. Re: Why is my jsfunction action only called once?
                    jackielii

                    Just did, still doen't work.

                     

                    Original I tried it without eventsQueue ignoreDupResponses requestDelay, it didn't work, and then I tried with the parameters on.

                    • 7. Re: Why is my jsfunction action only called once?
                      jackielii

                      Found the answer myself:

                       

                      Firstly, I turned on the log:

                      {code:xml}<a:log level="ALL" popup="false" width="400" height="200"/>{code}

                      And found out, if two requests in one request queue are "similar", (didn't find out how is similar), the second request is ignored. so the problem is down to specify a difference request queue, (or similarityGroupingId, which is for grouping the jsFunction, maybe this is how to identify is it's "similar"). The problem is, though, the eventsQueue parameter is evaluated before <a:actionparam>, so I can't set the eventsQueue using #{bean.data}

                       

                      So my solution is:

                      create another closure myself, keep the same id and name as the jsFunction:

                       

                      {code:xml}<a:jsFunction name="saveEdit" id="saveEditFunc" action="#{bean.saveEdit()}"

                          <a:actionparam name="data" assignTo="#{bean.data}" />

                      </a:jsFunction>

                      <script type="text/javascript">

                          saveEdit=function(data){

                              A4J.AJAX.Submit('_viewRoot','common',null,{

                                  'oncomplete':function(request,event,data){},

                                  'similarityGroupingId':'saveEditFunc'+data,

                                  'parameters':{'data':data,'saveEditFunc':'saveEditFunc'} ,

                                  'eventsQueue':'queue_saveEdit',

                                  'actionUrl':'/work/task/edit.seam'}

                              )

                          };

                      </script>{code}

                       

                       

                       

                      Thanks for everyone who commented(although just liumin hu) and viewed this thread.

                      Jackie