-
24 Dec 2012 12:10 PM #1
Unanswered: How to reject record on Ext.direct server exception
Unanswered: How to reject record on Ext.direct server exception
When you save a record with Ext.direct proxy and a server exception occurs, how can I reject the record? Callback function is not called, and there is no exception function on Ext.data.Operation.
I did find an ugly workaround, but there's gotta be a better way to do this ... or not???
Code:// record with a fully working Ext.direct proxy var record; // create exception handler var exceptionFn = Ext.bind(function(record) { // reject record record.reject(); // remove listener if exception occured Ext.direct.Manager.un('exception', exceptionFn); }, this, [record]); // listen to Ext.direct exceptions Ext.direct.Manager.on('exception', exceptionFn); // save record record.save({ callback: function(records, operation) { // this never gets called if server exception occurs // remove listener if exception did not occur Ext.direct.Manager.un('exception', exceptionFn); } });
-
26 Dec 2012 8:47 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 34,107
- Vote Rating
- 453
- Answers
- 3156
Couple issues I see. Using Ext.direct means you may have multiple requests bundled into a single request so if one fails then the others fail but that doesn't mean the record saving wasn't successful.
You shouldn't allow the direct router to fire anything that wouldn't give a successful JSON reading meaning if there was a server side error (like a PHP error). Each request needs to have success true/false to tell each request is successful or not.Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.


Reply With Quote