1. #1
    Ext JS Premium Member
    Join Date
    Aug 2011
    Location
    Greenville, SC
    Posts
    120
    Vote Rating
    9
    bmacdon1 will become famous soon enough

      0  

    Default Is a model required for an errorReader?

    Is a model required for an errorReader?


    Hello,
    I have been struggling attempting to get the errorReader(or even xml data) to work properly on a form submit without using a model. The code snippet below comes from the api section Ext.form.action.Submit and implies to me it is not necessary to build a model for a simple reader.

    Code:
        errorReader: new Ext.data.reader.Xml({            
                                    record : 'field',             
                                    success: '@success'         
                               }, [ 'id', 'msg' ])
    I ended up using the Extjs XML sample to get the submit somewhat working. This sample required the use of a model. On a side note, this functionality doesn't work for me on the sample page. The submit is always disabled.

    If I don't include a model I get an error "this.model is undefined." The closest post I've found dealing with a similar issue is here:

    Problems using action.Load with XML Reader (migrating from 3.x to 4.x)

    No one answered his question, but it seems similar to what I am dealing with. This is a snippet of my code. It is possible I am doing something wrong all together and it would be great if someone could point me in the right direction. And yes, I know its over kill to be doing this for a log in page, but I am attempting to rely on ExtJS framework to build everything.

    Code:
    var loginForm = Ext.create('Ext.form.Panel', 
            {            
                    title: 'Login Form',                
                    bodyPadding: 5,            
                    width: '462',            
                    height: '333',            
                    autoScroll:true,
                        url: '../login',
                        clientValidation:false,
                    errorReader: Ext.create('Ext.data.reader.Xml', {
                        record : 'MESSAGE',
                        success: '@success'
                    },['MESSAGE_TYPE'])
            });
            
    var loginFormButtonsubmit= Ext.create('Ext.Button',{
            text: 'Submit',    
            formBind: true,
            handler: function() 
            {
                var form = this.up('form').getForm(); 
                
                if (form.isValid()) 
                {
    
                    form.submit({
                        success: function(form, action){
                            alert('Success')   
                        },
                        failure: function(form, action){
                            alert('Failed')                
                        }
                    });
                } 
                else 
                { 
                    Ext.Msg.alert('', 'This page contains errors. Correct the errors indicated below each field, and then retry this action.')
                }
            }
        });
    
        loginForm.add(loginFormButtonsubmit);

  2. #2
    Ext JS Premium Member
    Join Date
    Aug 2011
    Location
    Greenville, SC
    Posts
    120
    Vote Rating
    9
    bmacdon1 will become famous soon enough

      0  

    Default


    Nice, to see the example is fixed now ;p

  3. #3
    Sencha User
    Join Date
    Jan 2012
    Posts
    4
    Vote Rating
    0
    robertb216 is on a distinguished road

      0  

    Default Did you ever get a resolution to this issue?

    Did you ever get a resolution to this issue?


    I have attempted the exact same thing for my login page. I'm use Ext 4.1 and get the error "this.model.prototype.fields.items;" undefined...

    On my form config..
    <code>
    errorReader: new Ext.data.reader.Xml({
    record : 'field',
    success: '@success'
    }, [ 'id', 'msg' ]
    ),
    </code>

    and in my controller with the "login button"
    <code>
    onLoginClick: function() {
    ....
    myForm.submit({
    method: 'POST',
    waitTitle: 'Connecting',
    waitMsg: 'Sending data...',


    success:function(form,action){
    ...do something like load new url...
    },
    failure:function(form, action){
    ... let user know that email/password was invalid...
    }
    });
    </code>

    this looks to be the same problem you were having.... any suggestions ??

  4. #4
    Sencha User
    Join Date
    May 2012
    Posts
    1
    Vote Rating
    0
    glandi is on a distinguished road

      0  

    Default


    If you don't have to rebind the xml response to the form,
    you can make an ajax request with form values as params and extract the desired node from the response with Ext.DomQuery.

    Code:
    var request = {  
        url: myUrl, params: myForm.getValues(), method:'post',
        callback: this.requestCallback, scope:this, 
    };
    Ext.Ajax.request(request);
    
    requestCallback:function(options, success, response) {
        var msg = null;
        if (success) {
           try {
             var xml = response.responseXML;
             success = Ext.DomQuery.selectValue('success', xml) == "true";
             if (!success) {
                msg = "Request failed";
             } 
          } catch(e) {
             msg = "Cannot decode XML response "+e +" "+ response.responseText;
          }
       } else {
          msg = response.responseText;
       }
       if (!success) {
            Ext.Msg.alert("Failure", msg);
       }
    }
    
    

  5. #5
    Sencha Premium Member koushlendr's Avatar
    Join Date
    Sep 2011
    Location
    Bangalore
    Posts
    10
    Vote Rating
    1
    koushlendr is on a distinguished road

      0  

    Default Problem with JSON Error reader for form

    Problem with JSON Error reader for form


    1. json response after form submit ::

    {"success":"false","errors":[{"id":"java.home","msg":"Java Home is required and cannot be empty"},{"id":"admin.password","msg":"AppServer Admin Password is required and cannot be empty"}]}

    2. ErrorReader configuration in form ::

    errorReader : new Ext.data.reader.Json({
    root: 'errors',
    successProperty: 'success',
    model : 'Manh.model.layout.install.InstallErrors'
    }),

    3. Model definition for error reader:

    Ext.define('Manh.model.layout.install.InstallErrors', {
    extend: 'Ext.data.Model',
    fields: ['id', 'msg']
    });

    Still error reader not working as i get model undefined in ext-all-dev.js on below lines.

    if (me.lastFieldGeneration !== me.model.prototype.fields.generation) {
    me.buildExtractors(true);
    }

    Need help to resolve this.

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..."