From 79fbe70111c32ebb8288dd7ae76d09d719acaef8 Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Thu, 9 Aug 2012 20:13:24 +0200 Subject: [PATCH] fix missing error messages for some json stores --- .../resources/js/rest/sonia.rest.jsonstore.js | 55 ++++++++++--------- 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/scm-webapp/src/main/webapp/resources/js/rest/sonia.rest.jsonstore.js b/scm-webapp/src/main/webapp/resources/js/rest/sonia.rest.jsonstore.js index 4227062c9e..0aa5768ac3 100644 --- a/scm-webapp/src/main/webapp/resources/js/rest/sonia.rest.jsonstore.js +++ b/scm-webapp/src/main/webapp/resources/js/rest/sonia.rest.jsonstore.js @@ -35,32 +35,37 @@ Sonia.rest.JsonStore = Ext.extend( Ext.data.JsonStore, { errorMsgText: 'Could not load items. Server returned status: {0}', constructor: function(config) { - var baseConfig = { - autoLoad: true, - listeners: { - // fix jersey empty array problem - exception: { - fn: function(proxy, type, action, options, response, arg){ - var status = response.status; - if ( status == 200 && action == 'read' && response.responseText == 'null' ){ - if ( debug ){ - console.debug( 'empty array, clear whole store' ); - } - this.removeAll(); - } else { - if (debug){ - console.debug( 'error during store load, status: ' + status ); - } - main.handleRestFailure( - response, - this.errorTitleText, - this.errorMsgText - ); - } - }, - scope: this + if ( ! config.listeners ){ + config.listeners = {}; + } + // fix jersey empty array problem + config.listeners.exception = { + fn: function(proxy, type, action, options, response, arg){ + var status = response.status; + if (debug){ + console.debug('store returned statuscode ' + status); } - } + if ( status == 200 && action == 'read' && response.responseText == 'null' ){ + if ( debug ){ + console.debug( 'empty array, clear whole store' ); + } + this.removeAll(); + } else { + if (debug){ + console.debug( 'error during store load, status: ' + status ); + } + main.handleRestFailure( + response, + this.errorTitleText, + this.errorMsgText + ); + } + }, + scope: this + } + + var baseConfig = { + autoLoad: true }; Sonia.rest.JsonStore.superclass.constructor.call(this, Ext.apply(baseConfig, config)); }