Results 1 to 2 of 2

Thread: errorReader Problem

    Success! Looks like we've fixed this one. According to our records the fix was applied for EXTJS-5138 in a recent build.
  1. #1
    Sencha Premium User
    Join Date
    Apr 2011
    Posts
    50

    Default errorReader Problem

    Test Case:
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
        <title></title>
        <link rel="stylesheet" type="text/css" href="../../Ext4/resources/css/ext-all.css"/>    
        <script type="text/javascript" src="../../Ext4/bootstrap.js"></script>
        <style type="text/css">
        </style>
    </head>
    <body>    
        <script type="text/javascript">
            Ext.define('FieldError', {
                extend: 'Ext.data.Model',
                fields: ['id', 'msg']
            });
    
            Ext.onReady(function(){
                if(Ext.BLANK_IMAGE_URL.substr(0,4)!="data"){                
                    Ext.BLANK_IMAGE_URL="./images/s.gif";
                }
                
                Ext.create("Ext.form.Panel",{
                    title:"Test",
                    width:400,
                    height:400,
                    renderTo:Ext.getBody(),
                    bodyStyle:"background:#DFE9F6",
                    bodyPadding:5,
                    defaultType:"textfield",
                    fieldDefaults:{labelWidth:80,                        
                        labelSeparator:"?",anchor:"0"
                    },                    
                    url:"error.xml",
                    errorReader:Ext.create("Ext.data.reader.Xml",{
                        model:FieldError,
                        root:"errors",
                        record:"error",
                        successProperty:"success"
                    }),
                    bbar:[
                        {text:"Save",handler:function(){
                            var f=this.up("form").getForm();
                            if(f.isValid())
                                f.submit();
                        }}
                    ],
                    items:[
                        {fieldLabel:"field1",name:"field1"},
                        {fieldLabel:"field2",name:"field2",msgTarget:"side"},
                        {fieldLabel:"field3",name:"field3",msgTarget:"title"},
                        {fieldLabel:"field4",name:"field4",msgTarget:"under"},
                        {fieldLabel:"field5",name:"field5",msgTarget:"label2"},
                        {xtype:"label",id:"label2"}
                    ]
                })
            });
        </script>
    </body>
    </html>
    Error.xml:
    Code:
    <message>
       <success>false</success>
      <errors>
        <error>
          <id>field1</id>
          <msg><![CDATA[Reurire]]></msg>
        </error>
        <error>
          <id>field2</id>
          <msg><![CDATA[Reurire]]></msg>
        </error>
        <error>
          <id>field3</id>
          <msg><![CDATA[Reurire]]></msg>
        </error>
        <error>
          <id>field4</id>
          <msg><![CDATA[Reurire]]></msg>
        </error>
        <error>
          <id>field5</id>
          <msg><![CDATA[Reurire]]></msg>
        </error>
      </errors>
    </message>
    I found the readRecords method of Ext.data.reader.Reader,it can not read data when success is false.
    Code:
    Code:
            if (success) {
                
                root = Ext.isArray(data) ? data : me.getRoot(data);
                
                if (root) {
                    total = root.length;
                }
    
              if (me.totalProperty) {
                    value = parseInt(me.getTotal(data), 10);
                    if (!isNaN(value)) {
                        total = value;
                    }
                }
    
               if (root) {
                    records = me.extractData(root);
                    recordCount = records.length;
                }
            }
            return new Ext.data.ResultSet({
                total  : total || recordCount,
                count  : recordCount,
                records: records,
                success: success,
                message: message
            });

  2. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,379

    Default

    I have added this to our bug tracker as the XML Form example isn't working. It should have two errors when you press submit.
    Mitchell Simoens @LikelyMitch

    Check out my GitHub:
    https://github.com/mitchellsimoens

    Posts are my own, not any current, past or future employer's.

Posting Permissions

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