Если вам нужно это только для распознавания, когда пользователь не аутентифицирован, вы можете подумать о том, чтобы сделать что-то еще. Как добавление обработчика в синглтон Ajax:
function addAjaxErrorHandler(object) {
Ext.Ajax.on('requestexception', function(conn, response, options, e) {
var statusCode = response.status,
errorText = null,
captionText = response.statusText;
// 404 - file or method not found - special case
if (statusCode == 404) {
Ext.MessageBox.alert('Error 404', 'URL ' + response.request.options.url + ' not found');
return;
}
if (response.responseText != undefined) {
var r = Ext.decode(response.responseText, true);
if (r != null) {
// 401 - not authenticated. For some reason we don't have authentication cookie anymore
if (r.ErrorCode == 401) {
Ext.MessageBox.alert('Error', 'You must log in to use application',
function() {
// do something when user is not authenticated
object);
return;
}
errorText = r.ErrorMessage;
}
if (errorText == null)
errorText = response.responseText;
}
if (!captionText)
captionText = 'Error ' + statusCode;
Ext.MessageBox.alert(captionText, errorText);
},
object);
}
Затем просто вызовите эту функцию из функции application.launch () и передайте объект приложения, чтобы область действия была определена.