1. #1
    Sencha User
    Join Date
    Dec 2011
    Posts
    5
    Answers
    1
    Vote Rating
    0
    silentreproach is on a distinguished road

      0  

    Default Answered: Stuck - MVC Application Architecture guide does not save to server

    Answered: Stuck - MVC Application Architecture guide does not save to server


    I've run through the "MVC Application Architecture" guide very carefully, several times. I get the correct console messages and results as the guide progresses up to a certain point.

    It stops working as described in the guide when I get to the "Saving to the Server" section. That is, the updateUsers.json data file does not have the expected dummy success response - the file is empty. The last entry in Chrome's network log is "dirty.gif" and not "updateUsers.json" as in the guide.

    I added a console message to the updateUser function to make sure the code was being executed. It seems as if the "this.getUsersStore().sync();" line is not doing anything.

    I would really like to have success with this guide before moving to the next step. Any gurus that can help?

  2. I found a solution. In the guide, there is a section called "Creating a Model and a Store". It describes how to edit app/view/user/List.js, as the guide says: "to simply reference the Store by id".

    The guide was unclear how to edit List.js and in several attempts I did not edit it correctly. So, here is what I believe List.js should ultimately contain and which helped me get past my obstacle:

    Code:
    Ext.define('AM.view.user.List' ,{
        extend: 'Ext.grid.Panel',
        alias : 'widget.userlist',
    
    
        //we no longer define the Users store in the `initComponent` method
        store: 'Users',
    
    
        title : 'All Users',
    
    
        initComponent: function() {
            this.columns = [
                {header: 'Name',  dataIndex: 'name',  flex: 1},
                {header: 'Email', dataIndex: 'email', flex: 1}
            ];
    
    
            this.callParent(arguments);
        }
    });

  3. #2
    Sencha User
    Join Date
    Dec 2011
    Posts
    59
    Answers
    6
    Vote Rating
    0
    1099511627776 is on a distinguished road

      0  

    Default


    Can you post some of your source code. so we can walk through it and figure where is a problem. Mainly I'm interested in how did you define a store

  4. #3
    Sencha User
    Join Date
    Dec 2011
    Posts
    5
    Answers
    1
    Vote Rating
    0
    silentreproach is on a distinguished road

      0  

    Default


    Sure, here is my app\store\Users.js

    Code:
    Ext.define('AM.store.Users', {
        extend: 'Ext.data.Store',
        model: 'AM.model.User',
        autoLoad: true,
    
    
        proxy: {
           type: 'ajax',
    
    
           api: {
               read: 'data/users.json',
               update: 'data/updateUsers.json'
           },
           reader: {
               type: 'json',
               root: 'users',
               successProperty: 'success'
           }
        }
    });
    and my app/controller/Users.js:

    Code:
    Ext.define('AM.controller.Users', {
        extend: 'Ext.app.Controller',
        stores: ['Users'],
        models: ['User'],
    
    
        views: [
            'user.List',
            'user.Edit'
        ],
    
    
        init: function() {
            this.control({
                'viewport > userlist': {
                    itemdblclick: this.editUser
                },
                'useredit button[action=save]': {
                    click: this.updateUser
                }
            });
        },
    
    
        editUser: function(grid, record) {
            var view = Ext.widget('useredit');
    
    
            view.down('form').loadRecord(record);
        },
    
    
        updateUser: function(button) {
            var win    = button.up('window'),
                form   = win.down('form'),
                record = form.getRecord(),
                values = form.getValues();
    
    
            record.set(values);
            win.close();
            this.getUsersStore().sync();
        }
    });
    If there's any other code you want, or there is a better way for me to post it, please let me know.

    Screenshot of Chrome's debugger after updateUser function:

    screenie.jpg
    Last edited by silentreproach; 2 Jan 2012 at 5:06 AM. Reason: added screenshot

  5. #4
    Sencha User
    Join Date
    Dec 2011
    Posts
    5
    Answers
    1
    Vote Rating
    0
    silentreproach is on a distinguished road

      0  

    Default


    Added code and screenshot. Still can't get the MVC Application Architecture guide to work as described. Anyone able to make it work?

  6. #5
    Sencha User
    Join Date
    Dec 2011
    Posts
    59
    Answers
    6
    Vote Rating
    0
    1099511627776 is on a distinguished road

      0  

    Default


    Can you put a breakpoint to

    this.getUsersStore().sync(); and trace down what it is doing ?

  7. #6
    Sencha User
    Join Date
    Dec 2011
    Posts
    5
    Answers
    1
    Vote Rating
    0
    silentreproach is on a distinguished road

      0  

    Default


    I found a solution. In the guide, there is a section called "Creating a Model and a Store". It describes how to edit app/view/user/List.js, as the guide says: "to simply reference the Store by id".

    The guide was unclear how to edit List.js and in several attempts I did not edit it correctly. So, here is what I believe List.js should ultimately contain and which helped me get past my obstacle:

    Code:
    Ext.define('AM.view.user.List' ,{
        extend: 'Ext.grid.Panel',
        alias : 'widget.userlist',
    
    
        //we no longer define the Users store in the `initComponent` method
        store: 'Users',
    
    
        title : 'All Users',
    
    
        initComponent: function() {
            this.columns = [
                {header: 'Name',  dataIndex: 'name',  flex: 1},
                {header: 'Email', dataIndex: 'email', flex: 1}
            ];
    
    
            this.callParent(arguments);
        }
    });

  8. #7
    Sencha User
    Join Date
    Jan 2012
    Posts
    19
    Answers
    1
    Vote Rating
    0
    wxkevin is on a distinguished road

      0  

    Default


    I have the exact same code as noted here but still don't see anything written to updateUsers.json.

  9. #8
    Sencha User
    Join Date
    Dec 2011
    Posts
    5
    Answers
    1
    Vote Rating
    0
    silentreproach is on a distinguished road

      0  

    Default


    Quote Originally Posted by wxkevin View Post
    I have the exact same code as noted here but still don't see anything written to updateUsers.json.
    Actually I had this problem also (nothing written to updateUsers.json), but I did not mention it. I did everything according to the tutorial and everything else worked as described except this last step. I still don't know why. Anyone else have this problem besides me and wxkevin?

  10. #9
    Sencha User
    Join Date
    Nov 2012
    Posts
    1
    Vote Rating
    0
    SwissNavy is on a distinguished road

      0  

    Default Should it even get updated?

    Should it even get updated?


    This thread is marked "Answered" - was it really? I got stuck on the same last step - updating updateUsers.json file. Another thread on the same topic (http://www.sencha.com/forum/showthread.php?246809) suggests that the file should not even get updated following just the tutorial's steps. Instead, you need to send the request to a script to do the update. So should it or should it not get updated iff one follows the tutorial?

    Thanks!

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