यदि आपको केवल यह पहचानने की आवश्यकता है कि उपयोगकर्ता प्रमाणीकृत नहीं है तो आप कुछ और करने पर विचार करना चाहेंगे।
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() फ़ंक्शन से इस फ़ंक्शन को कॉल करें और अगर परिभाषित तो गुंजाइश आवेदन वस्तु पारित: अजाक्स सिंगलटन करने के लिए कोई हैंडलर जोड़ने की तरह।
आप लॉगिन फॉर्म को दिखाने के लिए कनेक्शन को ओवरराइड क्यों करना चाहते हैं? लॉगिन फॉर्म के साथ उपयोगकर्ता को प्रस्तुत करने के लिए यदि वह प्रमाणित नहीं है? – sha
बिल्कुल। और यदि सत्र का समय भी समाप्त हो जाता है। –
मैंने अजाक्स त्रुटियों के लिए वैश्विक हैंडलर जोड़ा और वहां गैर-प्रमाणीकृत त्रुटियों का विश्लेषण किया। शायद यह ऐसा कुछ है जो आपको भी अनुकूल करेगा। – sha