-
7 Dec 2011 9:43 AM #1
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.
This code will throw message like: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.someCallback, this); // <- there its began
},
someCallback: function() { console.log('hello world'); }
});
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,
-
7 Dec 2011 9:51 AM #2Sencha - Sencha Touch Dev Team
- Join Date
- Mar 2007
- Location
- Redwood City, California
- Posts
- 3,651
- Vote Rating
- 14
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.
-
7 Dec 2011 9:58 AM #3
Good,
temporary solution is to put validIdRegex: /^([\w\.\-]+)$/ on MyApp.model.Container
-
7 Jan 2012 1:33 PM #4
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!
-
7 Jan 2012 2:43 PM #5
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.someCallback, this); // <- there its began
},
someCallback: function() { console.log('hello world'); }
});
-
7 Jan 2012 3:08 PM #6
-
17 Jan 2012 2:20 AM #7
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?
-
28 Jan 2012 12:49 PM #8Sencha - Sencha Touch Dev Team
- Join Date
- Mar 2007
- Location
- Haarlem, Netherlands
- Posts
- 1,235
- Vote Rating
- 4
This has been fixed. If I run the following code on the latest code branch it works as expected.
Closing this ticket for now, but please let us know if you still experience issues with this with PR4 or the next release.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 }); } });
Success! Looks like we've fixed this one. According to our records the fix was applied for
TOUCH-1197
in
2.0.



Reply With Quote
