From a8eb96e06a0499024f2a5d87fb5abf917bc599a8 Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Sun, 5 Sep 2010 16:34:04 +0200 Subject: [PATCH] added Sonia.rest.JsonStore --- scm-webapp/src/main/webapp/index.html | 1 + .../main/webapp/resources/js/sonia.group.js | 2 +- .../main/webapp/resources/js/sonia.rest.js | 28 +++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 scm-webapp/src/main/webapp/resources/js/sonia.rest.js diff --git a/scm-webapp/src/main/webapp/index.html b/scm-webapp/src/main/webapp/index.html index 77242c190a..d653bfc0a7 100644 --- a/scm-webapp/src/main/webapp/index.html +++ b/scm-webapp/src/main/webapp/index.html @@ -13,6 +13,7 @@ + diff --git a/scm-webapp/src/main/webapp/resources/js/sonia.group.js b/scm-webapp/src/main/webapp/resources/js/sonia.group.js index fec62c4ecf..ba8b0be339 100644 --- a/scm-webapp/src/main/webapp/resources/js/sonia.group.js +++ b/scm-webapp/src/main/webapp/resources/js/sonia.group.js @@ -98,7 +98,7 @@ var groupSelModel = new Ext.grid.RowSelectionModel({ singleSelect: true }); -var groupStore = new Ext.data.JsonStore({ +var groupStore = new Sonia.rest.JsonStore({ url: restUrl + 'groups.json', root: 'groups', fields: [ diff --git a/scm-webapp/src/main/webapp/resources/js/sonia.rest.js b/scm-webapp/src/main/webapp/resources/js/sonia.rest.js new file mode 100644 index 0000000000..1a548f93f6 --- /dev/null +++ b/scm-webapp/src/main/webapp/resources/js/sonia.rest.js @@ -0,0 +1,28 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +Ext.ns("Sonia.rest"); + +Sonia.rest.JsonStore = Ext.extend( Ext.data.JsonStore, { + + constructor: function(config) { + var baseConfig = { + autoLoad: true, + listeners: { + // fix jersey empty array problem + exception: { + fn: function(proxy, type, action, options, response, arg){ + if ( action == "read" && response.responseText == "null" ){ + this.removeAll(); + } + }, + scope: this + } + } + }; + Sonia.rest.JsonStore.superclass.constructor.call(this, Ext.apply(config, baseConfig)); + } + +});