5 Replies Latest reply on Feb 5, 2009 5:48 AM by yoghoyogho

    Handling bad connections

    yoghoyogho

      I'd like Richfaces to fail fast when the connection is lost or the server somehow can't be reached. How can I notify the user that the server is not being reached when for example I'm doing a a4j:form post ? I've tried shutting down the server and doing a post and I still get to see the a4j:status screen I've built in. The post will fail (I can see it failing in Firebug) and the oncomplete event of a4j:status is fired.
      For the user this seems like his request has succeeded, but in fact it didn't.
      I'd rather see a warning that the server can't be reached.
      Can anyone be so kind to point me in the right direction how to solve this issue?

        • 1. Re: Handling bad connections
          ilya_shaikovsky

          our components has ontimeout attribute. Event fired when the request timed out.

          • 2. Re: Handling bad connections
            yoghoyogho

            That's a blazing fast reply :-)

            Let me be more specific:

            <a4j:form id="orderForm" ajaxSubmit="true">
             <a4j:status id="orderStatus" onstart="showStatusModal();" onstop="hideStatusModal();"/>
             <a4j:jsFunction name="sendOrderValue" action="#{orderBean.orderArticle}" reRender="articlePanel">
             <a4j:actionparam name="count" assignTo="#{orderBean.count}"/>
             <a4j:actionparam name="item" assignTo="#{orderBean.item}"/>
             </a4j:jsFunction>
            </a4j:form>
            


            Where would ontimeout need to be inserted? I ask this, because I don't see ontimeout documented for both a4j:form as a4j:jsFunction

            • 3. Re: Handling bad connections
              ilya_shaikovsky

              sorry for confusing you.. Thinked about timeout attribute.. Now will check and clarify..

              • 4. Re: Handling bad connections
                ilya_shaikovsky

                I've used timeout on command button defined to 1000mls and in the button action used thread.sleep(3000); to simulate the timout.

                for this case out standard error handlers described in documentation "basic concepts" section works fine:

                <script type="text/javascript">
                 A4J.AJAX.onError = function(req, status, message){
                 window.alert(status + message);
                 }
                 </script>


                500 Request timeout alert appears. You could redefined the handler code with any you need.

                • 5. Re: Handling bad connections
                  yoghoyogho

                  This was exactly what I was looking for. I've tried it and it works. Thanks a lot!