1. #1
    Sencha User
    Join Date
    Jul 2012
    Location
    Italy
    Posts
    84
    Answers
    1
    Vote Rating
    4
    Tegola is on a distinguished road

      0  

    Default Unanswered: Model save() method not dealing with mappings

    Unanswered: Model save() method not dealing with mappings


    Hello,
    I'm working with a model that use a mapping, and I'm seeing a different behavior with GET and POST, with POST not getting all data.

    Here's the simplified version of my model:
    Code:
    Ext.define('MyMessage', {
        extend: 'Ext.data.Model',
        config: {
            fields: [
                { name: 'id', type: 'int' },
                { name: 'title', type: 'string' },
                { name: 'body', type: 'string' },
            ],
            associations: [
                { type: 'belongsTo', model: 'MyUser', foreignKey: 'author.id' },
            ]
        }
    });
    When calling MyMessage.load(<id>), the "author.id" field works fine.
    But then if I call:
    Code:
    var newMsg = Ext.create('MyMessage', {
        title: 'MyTitle',
        body: 'MyBody'
    });
    
    
    newMsg.save();
    The record is saved, the local client data is updated except for the "author.id" association, which is undefined. Even tough the data returned from the server has the "author" object inside.

    Is that normal?
    Last edited by Tegola; 20 Dec 2012 at 3:52 AM. Reason: Spelling

  2. #2
    Sencha User
    Join Date
    Dec 2011
    Posts
    154
    Answers
    7
    Vote Rating
    3
    coolfish is on a distinguished road

      0  

    Default


    I don't see in your code where you tell newMessage who the author of the message is?

  3. #3
    Sencha User
    Join Date
    Jul 2012
    Location
    Italy
    Posts
    84
    Answers
    1
    Vote Rating
    4
    Tegola is on a distinguished road

      0  

    Default


    You're right, that's because I'm logged in and the server knows who is the author. Rest assured, the author object is there:
    Code:
    {
    	"message": {
    		"id": "125",
    		"title": "MyTitle",
    		"body": "MyBody",
    		"author": {
    			"id": "2",
    			"name": "User name",
    			"email": "user@email.com"
    		}
    	}
    }

  4. #4
    Sencha User
    Join Date
    Jul 2012
    Location
    Italy
    Posts
    84
    Answers
    1
    Vote Rating
    4
    Tegola is on a distinguished road

      0  

    Default


    Also, the latest reader data (newMsg.getProxy().getReader().metaData) contains the right data.

    I'm stuck :|

  5. #5
    Sencha User
    Join Date
    Jul 2012
    Location
    Italy
    Posts
    84
    Answers
    1
    Vote Rating
    4
    Tegola is on a distinguished road

      0  

    Default


    I've studied the entire Ext.data section and I couldn't find a solution.
    Do somebody have any clue?

Thread Participants: 1

Tags for this Thread

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