[CLOSED] Handle lost internet connection

  1. #1

    [CLOSED] Handle lost internet connection

    Hi

    currently I am developing an application that needs to tell the user if the internet connection is lost.

    All these actions are DirectMethods or store reloads.

    Currently I am getting this standard ext.net window with the title "Request Failure"

    Status Code:
    Status Text:

    Is there a way to set a default text for that window like "Try again later, please check your internet connection ..."

    Regards
    Last edited by Daniil; Feb 04, 2014 at 11:37 AM. Reason: [CLOSED]
  2. #2
    Hi @blueworld,

    I can suggest the following.
    <ext:ResourceManager runat="server" ShowWarningOnAjaxFailure="false">
        <Listeners>
            <AjaxRequestException Handler="/* show your custom failure window */" />
        </Listeners>
    </ext:ResourceManager>
    The default failure window is being shown by Ext.net.DirectEvent.showFailure.
  3. #3
    Hi Daniil,

    I have a directmethod with failure handler. I would like to show an Alert with a different Text, but the failure window is showing at the same time.
    Is there a way to disable the failure window for that event?
    Or is it possible to change the Text of the failure window for that moment, and set it back to default in the failure handler?

    
    App.direct.doSomething(var1,var2, { 
             failure: function (message)
                     {
                       // Show alert but NOT the request failure window
                     }
                                                       });
    Last edited by blueworld; Jan 29, 2014 at 2:32 PM.
  4. #4
    Hmm. a failure window should not be shown if there is a failure handler.

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        [DirectMethod]
        public void TestDirectMethod()
        {
            throw new Exception();
        }
    </script>
    
    <!DOCTYPE html>
    <html>
    <head runat="server">
        <title>Ext.NET v2 Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            <ext:Button 
                runat="server" 
                Text="Click me" 
                Handler="App.direct.TestDirectMethod({ failure: function() { console.log('failure'); }})" />
        </form>
    </body>
    </html>
    Or is it possible to change the Text of the failure window for that moment, and set it back to default in the failure handler?
    Hmm, seems I don't understand the requirement. Please elaborate.
  5. #5
    Hi Daniil,

    please see this simple Demo.
    console.log is executed but the window is shown at the same time.
    Please note that I have used a custom handler.


    
    <%@ Page Language="VB" %>
    
    <%@ Import Namespace="System.Collections.Generic" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <!DOCTYPE html>
    
    <html>
    <head id="Head1" runat="server">
        <title></title>
        <script runat="server">
     
            <DirectMethod()>
            Public Sub MyEvent()
                
                Dim emptyList As Generic.List(Of Integer)
                
                Dim number As Integer = emptyList(1)
                
            End Sub
    
        </script>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager ID="ResourceManager1" runat="server">
    
                <Listeners>
                    <AjaxRequestException Handler="Ext.Msg.alert('Error', 'There was an error!')" />
                </Listeners>
    
            </ext:ResourceManager>
    
            <ext:Button runat="server" Text="Click me">
                <Listeners>
                    <Click Handler="App.direct.MyEvent({failure: function(){console.log('Failure');}})" />
                </Listeners>
            </ext:Button>
        </form>
    </body>
    </html>
  6. #6
    What window do you mean? Do you mean your alert window?
    If yes then it is expected behaviour because it is your code shown the alert. We cannot block it

    When Daniil said
    Hmm. a failure window should not be shown if there is a failure handler.
    then it meant Ext.Net error window
    Standard Ext.Net error window is not shown in your case
  7. #7
    Quote Originally Posted by Vladimir View Post
    What window do you mean? Do you mean your alert window?
    If yes then it is expected behaviour because it is your code shown the alert. We cannot block it

    When Daniil said

    then it meant Ext.Net error window
    Standard Ext.Net error window is not shown in your case
    Thank you Vladimir.
    I have a "please check your internet connection" alert window, instead of the default request-failure window.

    I have an event, that could throw an exception if a unique constraint has been violated.

    Is there any way, to show a different message if that happens?

    Can I change the AjaxRequestException-Handler by code? If yes, I could set a different Text before the event ('Name does already exist'), and after that event (sucess or failure), I could change it back to the old text('Please check your internet connection').
  8. #8
    So, you want to change the error message in a DirectMethod's failure handler, to get it appeared in the AjaxRequestException listener?

    If so, it looks impossible, because the AjaxRequestException event fires before a DirectMethod's failure handler.

    Could you, please, clarify why you don't want to do all the required things directly inside the AjaxRequestException listener?

Similar Threads

  1. Replies: 0
    Last Post: Feb 03, 2013, 1:40 AM
  2. Ext.Net and slow connection
    By threewonders in forum 1.x Help
    Replies: 1
    Last Post: May 17, 2012, 5:43 PM
  3. Replies: 1
    Last Post: Nov 23, 2011, 8:28 AM
  4. Replies: 3
    Last Post: Sep 08, 2011, 5:38 AM
  5. [CLOSED] internet explorer cannot open the internet site
    By speedstepmem4 in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Apr 28, 2009, 10:30 AM

Posting Permissions