8 Replies Latest reply on Sep 4, 2013 6:56 PM by mechtatel

    RF5: ajax request oncomplete issue

    mechtatel

      Hi,

       

      I have a issue with the oncomplete event when I'm using r:ajax or r:commandButton. More specifically the problem(maybe bug) appear when is used the next code:

       

            onbegin="disableButton(this)" oncomplete="enableButton(this)"

       

      The enableButton function is executed when the oncomplete is fired, but the parameter this is  not passed correctly. The onbegin is working fine.

       

      I'm using Richfaces 5, jsf 2.2.

        • 1. Re: RF5: ajax request oncomplete issue
          lfryc

          Hey H G, :-)

           

          could you share with us a javascript stack trace of a enableButton invocation?

           

          I guess it might be richfaces.js bug.

           

          Hint: Debugging RichFaces 5 Issues

          • 2. Re: RF5: ajax request oncomplete issue
            mechtatel

            Of course Lukáš,

             

             

            RichFaces: New request added to queue. Queue requestGroupingId changed to cmdbX

             

            log.js...chfaces (línea 175)

             

            RichFaces: Queue will wait 0ms before submit

             

            log.js...chfaces (línea 175)

             

            RichFaces: richfaces.queue: will submit request NOW

             

            log.js...chfaces (línea 175)

             

            RichFaces: Received 'begin' event from <a id=cmdbX  ...>

             

            log.js...chfaces (línea 175)

            POST http://localhost:8080/portal/register.jsf

               

            200 OK

                    96ms   

            jsf.js...lopment (línea 1812)

             

            RichFaces: Received 'beforedomupdate' event from <a id=cmdbX  ...>

             

            log.js...chfaces (línea 175)

             

            RichFaces: [object Object]

             

            log.js...chfaces (línea 175)

             

            RichFaces: [object Object]

             

            RichFaces: richfaces.queue: ajax submit error

             

            log.js...chfaces (línea 175)

             

            RichFaces: richfaces.queue: Nothing to submit

             

            log.js...chfaces (línea 175)

             

            RichFaces: Received 'error@malformedXML' event from <a id=cmdbX  ...>

             

                

                

            _log()log.js...chfaces (línea 175)

            level =

             

            "error"

             

            message =

             

            "Received 'error@malform...btn-default btn-lg ...>"

             

            (?)()log.js...chfaces (línea 262)

            message =

             

            "Received 'error@malform...btn-default btn-lg ...>"

             

            error()richfaces.js.jsf (línea 291)

            text =

             

            "Received 'error@malform...btn-default btn-lg ...>"

             

            jsfAjaxLogAdapter()log.js...chfaces (línea 354)

            data = Object { type=

             

            "error"

             

            , status=

             

            "malformedXML"

             

            , source=a#cmdbX.btn, más...}

            (?)()richfaces.js.jsf (línea 478)

            eventData = Object { type=

             

            "error"

             

            , status=

             

            "malformedXML"

             

            , source=a#cmdbX.btn, más...}

            sendError()jsf.js...lopment (línea 1883)

            request = XMLHttpRequest { readyState=

             

            4

             

            , timeout=

             

            0

             

            , withCredentials=

             

            false

             

            , más...}

            context = Object { element=a#cmdbX.btn, form=form#formTypeUser, formid=

             

            "formTypeUser"

             

            , más...}

            status =

             

            "malformedXML"

             

            description =

             

            "During update: javax.faces.ViewState not found"

             

            serverErrorName =

             

            undefined

             

            serverErrorMessage =

             

            undefined

             

            response()jsf.js...lopment (línea 2751)

            request =

             

            undefined

             

            context =

             

            undefined

             

            response()richfaces.js.jsf (línea 678)

            request = XMLHttpRequest { readyState=

             

            4

             

            , timeout=

             

            0

             

            , withCredentials=

             

            false

             

            , más...}

            context = Object { element=a#cmdbX.btn, form=form#formTypeUser, formid=

             

            "formTypeUser"

             

            , más...}

            response()richfa....js.jsf (línea 443)

            request = XMLHttpRequest { readyState=

             

            4

             

            , timeout=

             

            0

             

            , withCredentials=

             

            false

             

            , más...}

            context = Object { element=a#cmdbX.btn, form=form#formTypeUser, formid=

             

            "formTypeUser"

             

            , más...}

            response()richfa....js.jsf (línea 72)

            request = XMLHttpRequest { readyState=

             

            4

             

            , timeout=

             

            0

             

            , withCredentials=

             

            false

             

            , más...}

            context = Object { element=a#cmdbX.btn, form=form#formTypeUser, formid=

             

            "formTypeUser"

             

            , más...}

            onComplete()jsf.js...lopment (línea 1705)

            onreadystatechange()

             

               

            console[level](logMsg);

             

            log.js...chfaces (línea 175)

             

            RichFaces: [200] During update: javax.faces.ViewState not found

               

            console[level](logMsg);

             

            log.js...chfaces (línea 175)

             

            RichFaces: Received 'complete' event from <a id=cmdbX  ...>

             

             

            This is the code on enableButton:

             

            function enableButton(object) {

                try{

                    object.removeAttribute('disabled');

                }catch(err){alert(err.message);}

            }

             

            The alert is rising: object.removeAttribute is not a function

             

            If I use #{r:clientId('cmdbX')} instead of 'this' is working fine, but 'this' is much more better

             

            javax.faces.ViewState not found is maybe related to https://community.jboss.org/message/833433#833433

            • 3. Re: RF5: ajax request oncomplete issue
              bleathem

              Can you include your javascript function definitions to better understand what you are trying to achieve?

              • 4. Re: RF5: ajax request oncomplete issue
                mechtatel

                Hi Brian,

                 

                function enableButton(object) {

                    try{

                        object.removeAttribute('disabled');

                    }catch(err){alert(err.message);}

                }

                • 5. Re: RF5: ajax request oncomplete issue
                  bleathem

                  Great, that helps.  Next:

                  but the parameter this is  not passed correctly. The onbegin is working fine.

                   

                  When you say "not passed correctly", what do you mean?  It's null? it's the wrong object? is so, what object is it?

                  • 6. Re: RF5: ajax request oncomplete issue
                    mechtatel

                    I checked it. It's a wrong object. Is the JS Window object.

                     

                    Probably is related to the scope of 'this'  maybe  anonymous function on RF code.

                    • 7. Re: RF5: ajax request oncomplete issue
                      bleathem

                      Thanks for clarifying. Can you file a jira issue with these details?  Also, if you could check if this worked with earlier Mojarra (2.1.x) and/or RichFaces (4.3.x) release that would help out too.  Regressions carry a lot of weight.

                      • 8. Re: RF5: ajax request oncomplete issue
                        mechtatel

                        I released that the bug already exists - https://issues.jboss.org/browse/RF-12292