Two options:
In addition to using
connectOnStartup
property in initOptions.js, also use theonConnectionFailure
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 }, ... ...
Do not use the
connectOnStartup
property. Instead, useWL.Client.connect
to connect to the server when appropriate. For example, inwlCommonInit()
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 }