improve session timeout handling at the repository grid

This commit is contained in:
Sebastian Sdorra
2012-08-17 09:00:56 +02:00
parent 6a11c02dd0
commit ae11f28757
3 changed files with 28 additions and 25 deletions

View File

@@ -109,7 +109,8 @@ Sonia.repository.Grid = Ext.extend(Sonia.rest.Grid, {
load: {
fn: this.storeLoad,
scope: this
}
},
exception: Sonia.rest.ExceptionHandler
}
});

View File

@@ -30,3 +30,28 @@
*/
Ext.ns("Sonia.rest");
Sonia.rest.exceptionTitleText = 'Error';
Sonia.rest.exceptionMsgText = 'Could not load items. Server returned status: {0}';
Sonia.rest.ExceptionHandler = 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,
Sonia.rest.exceptionTitleText,
String.format(Sonia.rest.exceptionMsgText, status)
);
}
}

View File

@@ -31,36 +31,13 @@
Sonia.rest.JsonStore = Ext.extend( Ext.data.JsonStore, {
errorTitleText: 'Error',
errorMsgText: 'Could not load items. Server returned status: {0}',
constructor: function(config) {
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
);
}
},
fn: Sonia.rest.ExceptionHandler,
scope: this
}