Success! Looks like we've fixed this one. According to our records the fix was applied for TOUCH-4236 in a recent build.
  1. #1
    Sencha User
    Join Date
    Apr 2012
    Posts
    82
    Vote Rating
    1
    markevans is on a distinguished road

      1  

    Default Error on load() or sync() with localstorage in ST2.2.0 RC

    Error on load() or sync() with localstorage in ST2.2.0 RC


    REQUIRED INFORMATION

    Ext version tested:
    • ST 2.2.0 Release Candidate
    Browser versions tested against:
    • Chrome
    Description:
    • Store/models with proxy 'type' of 'localstorage' that contain a 'date' field in the model will not "load()" or "sync()". When the app executes these methods, the following error is thrown: Uncaught TypeError: Object [object Object] has no method 'getDefaultDateFormat' .
    Steps to reproduce the problem:
    • Create store. Create model for store that has a date field in it with proxy type set to 'localstorage'.
    • Attempt to 'load()' or save records to the localstorage with sync().
    The result that was expected:
    • No error.
    The result that occurs instead:
    • Error: Uncaught TypeError: Object [object Object] has no method 'getDefaultDateFormat'
    Test Case:

    Code:
    var ts = new Blank.store.TestStore();
    console.log('about to load store');
    ts.load();
    var recZero = ts.getAt(0);
    console.log('retrieved record:');
    console.log(recZero);
    console.log('loaded store');
    var tm = Ext.create('Blank.model.TestModel',
        {    "rememberlogin"      : true,
            "instanceid"          : "515",
            "dataasofdate"        : new Date(1364664723693),
            "dataasofdate_label"  : "Today, 1:32pm",
            "sessionid"           : "1255709312",
            "authtype"            : "tally",
            "rememberloginuserid" : "14",
            "loginstatus"         : "Logged in.",
            "loggedin"            : true,
            "pwlength"            : 5,
            "unviewedalerts"      : null,
        });
    console.log('stored record');
    console.log(tm);
    console.log('going to add() model to store');
    ts.add(tm);
    console.log('done adding model to store');
    console.log('going to sync() store');
    ts.sync();
    Model:

    Code:
    Ext.define('Blank.model.TestModel', {    extend: 'Ext.data.Model',
    
    
        requires: [ 'Ext.data.identifier.Uuid',
                     'Ext.data.proxy.LocalStorage'],
    
    
        config: {
            identifier: 'uuid',
            fields:     [
                        { name: 'instanceid', type: 'string' },
                        { name: 'dataasofdate', type: 'date' },
                        { name: 'dataasofdate_label', type: 'string' },
                        { name: 'sessionid', type: 'string' },
                        { name: 'authtype', type: 'string' },
                        { name: 'rememberlogin', type: 'boolean' },
                        { name: 'rememberloginuserid', type: 'string' },
                        { name: 'loginstatus', type: 'string' },
                        { name: 'loggedin', type: 'boolean' },
                        { name: 'pwlength', type: 'integer' },
                        { name: 'unviewedalerts', type: 'integer' }
                        ],
    
    
                        proxy: {
                            type: 'localstorage',
                            id: 'testmodels'
                        }
        }
    });
    Store:
    Code:
    Ext.define('Blank.store.TestStore', {    extend: 'Ext.data.Store',
        
        config: {
            model: 'Blank.model.TestModel',
            storeId: 'TestModels'
        }
    });



    HELPFUL INFORMATION
    Screenshot or Video:
    • none
    See this URL for live test case:
    • none
    Possible fix:
    • not provided
    Additional CSS used:
    • none
    Operating System:
    • MacOS 10.8

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,118
    Vote Rating
    855
    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


    Thanks for the report! I have opened a bug in our bug tracker.

  3. #3
    Sencha User
    Join Date
    Feb 2013
    Posts
    9
    Vote Rating
    0
    hongaar is on a distinguished road

      0  

    Default


    Seems that the WebStorage.readDate() uses Ext.Date.format instead of Ext.Date.parse (line 433 of WebStorage.js). Changing that fixed it for me.

    Although my exception is a bit different: Uncaught TypeError: Object [object String] has no method 'getFullYear'
    Last edited by hongaar; 1 Apr 2013 at 8:48 AM. Reason: added exception

  4. #4
    Sencha User
    Join Date
    Apr 2012
    Posts
    82
    Vote Rating
    1
    markevans is on a distinguished road

      0  

    Default


    Thanks for the suggestion. When I change that line (433) to return Ext.Date.parse(date, dateFormat) instead of return Ext.Date.format(date, dateFormat) I continue to get the error I was getting originally, which is tied to line 426: (vardateFormat=field.getDateFormat()||this.getDefaultDateFormat()).

    If you have any other thoughts, let me know. Cheers.

  5. #5
    Sencha Premium Member
    Join Date
    Sep 2009
    Posts
    35
    Vote Rating
    5
    Aldri is on a distinguished road

      1  

    Default


    It seems that webstorage is trying to get date format, and if you haven't specified it's trying to get the default format which doesn't exist.
    To avoid this error, if you are storing a date object, specify the date format "time" in your date fields. Example :

    Code:
    Ext.define('Shared.model.ArticleRead', {
        extend: 'Ext.data.Model',
        requires: 'Ext.data.identifier.Uuid',
        config: {
            fields: [
                {name: 'articleId', type: 'auto'},
                {name: 'date', type: 'date'}
            ],
            identifier: {type: "uuid"}
        }
    });
    Becomes :
    Code:
    Ext.define('Shared.model.ArticleRead', {
        extend: 'Ext.data.Model',
        requires: 'Ext.data.identifier.Uuid',
        config: {
            fields: [
                {name: 'articleId', type: 'auto'},
                {name: 'date', type: 'date', dateFormat: 'time'}
            ],
            identifier: {type: "uuid"}
        }
    });

  6. #6
    Sencha User
    Join Date
    Apr 2012
    Posts
    82
    Vote Rating
    1
    markevans is on a distinguished road

      0  

    Default


    Thanks, Aldri - that did fix it for me.

  7. #7
    Sencha User
    Join Date
    Jun 2012
    Posts
    5
    Vote Rating
    0
    ampamo is on a distinguished road

      0  

    Default


    Thanks, it also fixed the problem for me.