15 September 2008

Domino Server/ExtJS "Timeout" Script

Just reposting a bit of code I posted over on the ExtJS forums.

Here's a script that works all by itself -- just place it into your overrides file for your ExtJS/Domino app. Whenever your user's connection to the server has timed-out (and your app tries to fire an Ajax request), the timed-out Ajax request will be cached, the user will be prompted to log back in, and the previous Ajax request will be fired again, with no interruption in code execution. Pretty neat, eh?


DOMINO Server ExtJS "Server Timeout" Script

@author mdm-adph

@release 0.1

@license This script is licensed under the terms of
the Open Source LGPL 3.0 license. Commercial use is permitted to the extent
that the code/component(s) do NOT become part of another Open Source or Commercially
licensed development library or toolkit without explicit permission.

License details: http://www.gnu.org/licenses/lgpl.html

@usage Insert into your overrides file -- script will run automatically whenever
the Domino login page is returned from the server during the course of an
Ajax call. In your original callback, you will need to check for the presence
of a new response variable ("serverTimeout"), because this script will not stop
you original callback from firing.

Automatically tries to fire the last attempted Ajax request upon successful login with
the Domino server.


// Place this variable whereever you want -- it doesn't have to be in the global spec.
// Just make sure to update the script below if you move it.
VARS: {},
OBJ: {}

"requestcomplete": function(conn, response, options){

// Hide progress msg windows here if necessary
// Example: Ext.Msg.hide();

// If "timeout" page has been returned
if (response.responseText.indexOf('action="/names.nsf?Login"') !== -1)
// Cache last "true" ajax request, if this failed request isn't a login page
if (options.url != "/names.nsf?Login")
AJAXTIMEOUTCTRL.VARS.lastFailedAjaxRequest = options;

// Function run after user fills in reauthentication form
function serverLogin() {

Ext.Msg.wait("Getting authorization from server...", "Please Wait");
var password = Ext.getCmp("dominoLogin-password").getValue();
var username = Ext.getCmp("dominoLogin-username").getValue();

url: "/names.nsf?Login",
params: {
password: password,
username: username
// , RedirectTo:
// an added parameter "RedirectTo" can be added here if necessary
// to direct the Domino server to return a different page than normal
// upon successful login. This can be used to return updated server
// variables, user access levels, etc.
callback: function (options, success, response) {
if (success && !response.serverTimeout)
// Hide progress msg windows here if necessary
// Example: Ext.Msg.hide();

Ext.Msg.alert("Alert", "Your connection with the server has been reestablished.");

// Try to run the initially requested ajax
}; // end serverLogin()

// Create dominoLogin window object if not already created
AJAXTIMEOUTCTRL.OBJ.dominoLogin = new Ext.Window({
bodyStyle: "padding: 5px;",
border: false,
closable: false,
height: 160,
layout: "form",
labelAlign: "top",
modal: true,
plain: true,
resizable: false,
title: "Server Authentication Needed",
width: 315,

buttons: [{
text: 'OK',
handler: serverLogin

items: [{
xtype: "textfield",
fieldLabel: "Username",
id: "dominoLogin-username",
width: "100%",
value: "" // Add a variable holding current user's name here if necessary
xtype: "textfield",
fieldLabel: "Password",
id: "dominoLogin-password",
inputType: "password",
width: "100%",
listeners: {
"specialkey": function (theField, e) {
if (e.getKey() == e.ENTER) {

} // end if (!AJAXTIMEOUTCTRL.OBJ.dominoLogin)


// Delay the focus on the password input box, since the DOM doesn't like focusing while
// it's still manipulating things
Ext.getCmp("dominoLogin-password").focus(false, 500);

// Create additional response flag here so that initial ajax request's callback
// doesn't run
response.serverTimeout = true;

} // end if "timeout" page


  1. This is very nice. I can't wait to try it out. :)

  2. Sure thing! I had to sanitize the code before I posted it here (and at the ExtJS board), so my apologies if there's an error here or there.