Question

It possible to customize the Error Alert which popups while we set the connectOnStartup=true. I don't want my users to click on "Details" from that alert and view the details of the error message. I want to customize that alert with my custom message and action.

enter image description here

Was it helpful?

Solution

Two options:

  1. In addition to using connectOnStartup property in initOptions.js, also use the onConnectionFailure property:

    var wlInitOptions = {
        connectOnStartup : true,
    
        // # The callback function to invoke in case application fails to connect to Worklight Server
        onConnectionFailure: function () { 
            WL.SimpleDialog.show(
                "foo",
                "bar",
                [{text: "button",
                 handler : function() {alert("button pressed");}
                }]
             );
            // optionally add more logic here
        },
        ...
        ...
    
  2. Do not use the connectOnStartup property. Instead, use WL.Client.connect to connect to the server when appropriate. For example, in wlCommonInit()

    function wlCommonInit() { 
        WL.Client.connect({ onSuccess: success, onFailure: failure});
    }
    
    function success() {
        // ...
    }
    
    function failure() {
        WL.SimpleDialog.show(
            "foo",
            "bar",
            [{text: "button",
              handler : function() {alert("button pressed");}
            }]
       );
        // optionally add more logic here
    }
    
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top