Success! Looks like we've fixed this one. According to our records the fix was applied for TOUCH-1197 in a recent build.
  1. #1
    Sencha User demongloom's Avatar
    Join Date
    Apr 2008
    Location
    Israel
    Posts
    30
    Vote Rating
    3
    demongloom is on a distinguished road

      0  

    Default Observable: Invalid unique id regexp

    Observable: Invalid unique id regexp


    Hello Sencha

    I've found bug inside Observable.js, getObservableId function. This function checks for the observableId and if not exists, then id beign generated using getUniqueId function. After that it should over regexp validation using the validIdRegexp parameter.

    In my case it fails.

    PHP Code:
    Ext.define('MyApp.model.Container', {    
    extend'Ext.data.Model',
    fields: [
       { 
    name'id'type'int' },        
       { 
    name'name'type'string' },    
    ],

    associations: [        
    {            
        
    type:  'hasMany',            
        
    model'MyApp.model.Widget',            
        
    name:  'widgets',            
        
    primaryKey'id'        
    }
    ]

    constructor: function(config) {
        
    this.widgets().on('add'this.someCallbackthis);  // <- there its began
    },

    someCallback: function() { console.log('hello world'); }

    }); 
    This code will throw message like:
    Uncaught Error: [ERROR][MyApp.model.Container#getObservableId] Invalid unique id of 'MyApp.model.Container-ext-record-2' for this object

    It happens because generated id is contains "." symbols, but regexp allow only w+ and "-" symbols.

    Thanks,


  2. #2
    Sencha User Jamie Avins's Avatar
    Join Date
    Mar 2007
    Location
    Redwood City, California
    Posts
    3,661
    Vote Rating
    20
    Jamie Avins is a jewel in the rough Jamie Avins is a jewel in the rough Jamie Avins is a jewel in the rough

      0  

    Default


    There are a few related issues to this and we will be getting to them very soon. Thank you for the report and test case.

    Sencha Inc

    Jamie Avins

    @jamieavins

  3. #3
    Sencha User demongloom's Avatar
    Join Date
    Apr 2008
    Location
    Israel
    Posts
    30
    Vote Rating
    3
    demongloom is on a distinguished road

      0  

    Default


    Good,

    temporary solution is to put validIdRegex: /^([\w\.\-]+)$/ on MyApp.model.Container


  4. #4
    Ext JS Premium Member
    Join Date
    Nov 2009
    Location
    Cave
    Posts
    178
    Vote Rating
    2
    29er is on a distinguished road

      0  

    Default


    demongloom,
    could you give me more detail on where to put that valididRegex function. on the model ?
    i'm not quite sure where to put it but am having the same problems.
    Thanks!

  5. #5
    Sencha User demongloom's Avatar
    Join Date
    Apr 2008
    Location
    Israel
    Posts
    30
    Vote Rating
    3
    demongloom is on a distinguished road

      0  

    Default


    PHP Code:
    Ext.define('MyApp.model.Container', {    
    extend'Ext.data.Model',
    validIdRegex: /^([\w\.\-]+)$/,  //<------------- HERE
    fields: [
       { 
    name'id'type'int' },        
       { 
    name'name'type'string' },    
    ],

    associations: [        
    {            
        
    type:  'hasMany',            
        
    model'MyApp.model.Widget',            
        
    name:  'widgets',            
        
    primaryKey'id'        
    }
    ]

    constructor: function(config) {
        
    this.widgets().on('add'this.someCallbackthis);  // <- there its began
    },

    someCallback: function() { console.log('hello world'); }

    }); 


  6. #6
    Ext JS Premium Member
    Join Date
    Nov 2009
    Location
    Cave
    Posts
    178
    Vote Rating
    2
    29er is on a distinguished road

      0  

    Default


    thank you !

  7. #7
    Ext JS Premium Member
    Join Date
    Aug 2011
    Posts
    37
    Vote Rating
    0
    jakobgrannas is on a distinguished road

      0  

    Default


    This solved my problems with panels, but when I'm trying to extend Ext.List I get the "invalid unique id" error. However, if I change my code to extend Ext.Panel instead, it works. Is there something special about the way List id's work in comparison to how they work in Panels, or why doesn't it the regex work with Lists?

  8. #8
    Sencha User
    Join Date
    Mar 2007
    Location
    Haarlem, Netherlands
    Posts
    1,243
    Vote Rating
    10
    TommyMaintz will become famous soon enough TommyMaintz will become famous soon enough

      0  

    Default


    This has been fixed. If I run the following code on the latest code branch it works as expected.

    Code:
            Ext.define('MyApp.model.Widget', {
                extend: 'Ext.data.Model',
                config: {
                    fields: ['id', 'name']
                }
            });
    
            Ext.define('MyApp.model.Container', {
                extend: 'Ext.data.Model',
    
                config: {
                    fields: [
                       { name: 'id', type: 'int' },
                       { name: 'name', type: 'string' }
                    ],
    
                    associations: [{
                        type:  'hasMany',
                        model: 'MyApp.model.Widget',
                        name:  'widgets',
                        primaryKey: 'id'
                    }]
                },
    
                constructor: function(config) {
                    this.callParent(arguments);
                    this.widgets().on('addrecords', this.someCallback, this);  // <- there its began
                },
    
                someCallback: function() { console.log('hello world', arguments); }
            });
    
            Ext.setup({
                onReady: function() {
                    var instance = new MyApp.model.Container();
    
                    instance.widgets().add({
                        name: 'test',
                        id: 2
                    });
                }
            });
    Closing this ticket for now, but please let us know if you still experience issues with this with PR4 or the next release.