You found a bug! We've classified it as EXTJS-5622 . We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.
  1. #1
    Sencha User
    Join Date
    Dec 2011
    Posts
    220
    Vote Rating
    9
    dedoz will become famous soon enough

      0  

    Default 4.1 beta 3 - model.save() ignores response success state

    4.1 beta 3 - model.save() ignores response success state


    I posted this in Q&A forum and mitchell told me it could be a bug
    (sorry for my english)
    Ext version tested:
    ExtJs 4.1 beta 1 and beta 3
    cannot be tested in beta 2 because model.save() was broken in that version and was fixed back in beta 3.

    Browser versions tested against:
    Firefox 10.0.2
    Chrome 17.0.963.66

    Description:
    Its related to a http response with success:false.
    when success is false record.save() will save the new values anyway and phanthom will go false.

    this is important to me because i use success:false message:'unique,fieldname' to avoid saving records that breaks unique constrains and they are very common, and this only can be checked on server side.


    Steps to reproduce the problem:
    create any model with a direc proxy (i guess other proxys have the same problem i think is not related to the proxy)
    create an instance of the model
    save the model
    the response must include success:false

    The result that was expected:
    the record wont be set with the bad values after success:false
    also the record has to be phantom still, because save failed.

    also returning sucess:false i expected operation.wasSuccessful() = false
    when operation.response.success is false.

    The result that occurs instead:
    when success : false
    the record is set with the bad values.
    record.phatom = false.
    operation.wasSuccessful() = true even when operation.response.success is false
    record.reject() wont give me back the old values.


    Test Case:
    im using model with direct proxy and everything works fine, i can save to the database and get right success responses from server (prints the response message when success:false or prints "success" when sucess:true), everything is working fine but the problems describes above and below.
    Code:
        p = Ext.create('Person',{name:'robinson'});
        console.log(p.phantom); // true
        p.save({
            callback : function(record,operation)
            {    if (!operation.response.success)
                {   console.log('ERROR : ' + operation.response.message);
                    console.log(p.getData()); // has the name 'robinson' which is OK
                    p.reject(); // to reject the changed because success:false
                    console.log(p.getData()); // has the name 'robinson' which is not OK i cant get the old values back
                                            // just as example as we had an already loaded record.
                    operation.wasSuccessful() // prints true, should be false
                    console.log(p.phantom); // false, should be true 
                }
                else
                    console.log('sucess');
            }
        });
    my json response is
    Code:
    {    "type":"rpc",
            "tid":1,
            "action":"testQuery",
            "method":"Insert",
            "result":
                {"id":null,"name":"robinson"},
            "success":false,
            "message":"unique,name"
    }
    detects the success : false in the if(!operation.response.sucess) and prints the correct menssage to the console log.
    thats working fine.
    problem is , even when sucess is false, record changed to phantom:false (means it was saved to the server) i know i can set it manually to true again but i think shouldnt be happening and i dont know the consecuences of setting panthom back to true manually. also prolly is happening in store.sync() (havent tested) and there is goin to be harder to detect the record that needs to be set to phantom true again.
    also theres the problem that is set the values to the record no matter success state.
    and reject() wont give me the old values back, seems like after the save the record gots a commit() with the invalid values.

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,754
    Vote Rating
    828
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    And bug opened.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    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 in print!

    When posting code, please use BBCode's CODE tags.

Thread Participants: 1

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..." hd porno faketaxi