Results 1 to 3 of 3

Thread: [OPEN-1281] No exception event launched for DirectProxy read with success:false

    Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Ext JS Premium Member
    Join Date
    Aug 2009
    Location
    Magog, Canada
    Posts
    3

    Default [OPEN-1281] No exception event launched for DirectProxy read with success:false

    Ext version tested:

    • Ext 3.2 rev 2



    Adapter used:

    • ext



    Browser versions tested against:

    • FF3 (firebug 1.3.0.10 installed)



    Operating System:

    • Win 7



    Description:

    • When sending back json from the server with success:false to a read action of a DirectProxy used with a grid, the exception event is not launched.



    Debugging already done:

    • Found the problem in onRead method of DirectProxy :
      Code:
      onRead : function(action, trans, result, res) {
          var records;
          try {
              records = trans.reader.readRecords(result);
          }
          catch (ex) {
              this.fireEvent("loadexception", this, trans, res, ex);
      
              this.fireEvent('exception', this, 'response', action, trans, res, ex);
              trans.request.callback.call(trans.request.scope, null, trans.request.arg, false);
              return;
          }
          this.fireEvent("load", this, res, trans.request.arg);
          trans.request.callback.call(trans.request.scope, records, trans.request.arg, true);
      }
      readRecord Code from the JSON Writer is:
      Code:
      readRecords : function(o){
          this.jsonData = o;
          if(o.metaData){
              this.onMetaChange(o.metaData);
          }
          var s = this.meta, Record = this.recordType,
          f = Record.prototype.fields, fi = f.items, fl = f.length, v;
      
          var root = this.getRoot(o), c = root.length, totalRecords = c, success = true;
          if(s.totalProperty){
              v = parseInt(this.getTotal(o), 10);
              if(!isNaN(v)){
                  totalRecords = v;
              }
          }
          if(s.successProperty){
              v = this.getSuccess(o);
              if(v === false || v === 'false'){
                  success = false;
              }
          }
      
          return {
              success : success,
              records : this.extractData(root, true),
              totalRecords : totalRecords
          };
      }
      As we can see, it doesn't throw an exception when success is false, instead returning it in the result.

      The onWrite method, however, manages exceptions correctly:
      Code:
      onWrite : function(action, trans, result, res, rs) {
          var data = trans.reader.extractData(trans.reader.getRoot(result), false);
          var success = trans.reader.getSuccess(result);
          success = (success !== false);
          if (success){
              this.fireEvent("write", this, action, data, res, rs, trans.request.arg);
          }else{
              this.fireEvent('exception', this, 'remote', action, trans, result, rs);
          }
          trans.request.callback.call(trans.request.scope, data, res, success);
      }
      Something similar should be done for onRead.

    If it's not a bug and is intended, would you care to explain why the success property have no effect on DirectStores' read actions and also tell me if there is a standard way of managing success:false returns when loading the store ?

    Thanks.
    Frederick Deslandes
    Web applications developer
    Boreal Informations Strategies

  2. #2
    Sencha User Jamie Avins's Avatar
    Join Date
    Mar 2007
    Location
    Redwood City, California
    Posts
    3,661

    Default

    This does look like an oversight and should be in place for the onRead method as well.

  3. #3
    Ext JS Premium Member
    Join Date
    Aug 2009
    Location
    Magog, Canada
    Posts
    3

    Default

    Thanks.

    Here is my temporary fix:
    Code:
    // Add support for success property in DirectProxy read calls
    Ext.override(Ext.data.DirectProxy,
    {
        onRead : function(action, trans, result, res)
        {
            var records;
            try 
            {
                records = trans.reader.readRecords(result);
            }
            catch (ex) 
            {
                this.fireEvent("loadexception", this, trans, res, ex);
        
                this.fireEvent('exception', this, 'response', action, trans, res, ex);
                trans.request.callback.call(trans.request.scope, null, trans.request.arg, false);
                return;
            }
            
            if(trans.reader.getSuccess(result) === false)
            {
                this.fireEvent("loadexception", this, trans, res);
        
                this.fireEvent('exception', this, 'remote', action, trans, res.result);
                trans.request.callback.call(trans.request.scope, null, trans.request.arg, false);
                return;
            }
            
            this.fireEvent("load", this, res, trans.request.arg);
            trans.request.callback.call(trans.request.scope, records, trans.request.arg, true);
        }
    });
    Frederick Deslandes
    Web applications developer
    Boreal Informations Strategies

Similar Threads

  1. Replies: 4
    Last Post: 14 Oct 2009, 8:42 PM
  2. Replies: 1
    Last Post: 31 Jan 2008, 9:17 AM
  3. Replies: 0
    Last Post: 30 Jan 2008, 10:20 PM
  4. always success even w\ {success:false}
    By trinity in forum Ext 1.x: Help & Discussion
    Replies: 18
    Last Post: 27 Jun 2007, 5:15 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •