PDA

View Full Version : [DUPE-355]DirectProxy.onWrite ignores successProperty



cerad
10 Feb 2010, 11:50 AM
DirectProxy.onWrite always fires the store's write event even if the server indicates the write was a failure.

Current code:


onWrite : function(action, trans, result, res, rs) {
var data = trans.reader.extractData(result, false);
this.fireEvent("write", this, action, data, res, rs, trans.request.arg);
trans.request.callback.call(trans.request.scope, data, res, true);
}

At the very least it needs to fire an exception on failure. Of course since using exceptions to control flow is usually considered a bad idea it might be better to have a different event fire. But that would probably be a feature request. A sample fix:


onWrite : function(action, trans, result, res, rs)
{
// Actually a different fix for root issue
var data = trans.reader.extractData(result[trans.reader.meta.root], false);

// Only fire if success is true
var success = result[trans.reader.meta.successProperty];
if (success === true)
{
this.fireEvent("write", this, action, data, res, rs, trans.request.arg);
}
else
{
/* Not convinced this is really an exception, should be success or failure events */
this.fireEvent('exception', this, 'remote', action, trans, result, rs);
}
trans.request.callback.call(trans.request.scope, data, res, success);
}

Jamie Avins
10 Feb 2010, 11:52 AM
http://www.extjs.com/forum/showthread.php?t=83205

cerad
10 Feb 2010, 12:07 PM
I realize it is a dup but every time we try to get it fixed we get told to either post a bug report or generate some sort of test case. Very frustrating that something so simple has made it through several releases without being addressed.