-
2 Sep 2008 1:36 PM #1
naming conventions: id, xtype
naming conventions: id, xtype
Common naming convention for xtypes?
Just curious of any naming conventions being used for id's versus xtype. I had an inclination to use the same name.
Doesn't make a hill of bean difference, just thought I would see if there's a common convention floating around which if nothing else might make user extensions (xtype registrations) more uniform.Code:items: [{ xtype: 'panel-login', itemId: 'loginPanel', id: 'loginPanel', region: 'north', height: 50 },
I haven't tracked down what the problem is yet, but if you use the same id and xtype name it causes problems. For example, using something like:
and then doingCode:items: [{ xtype: 'loginPanel', itemId: 'loginPanel', id: 'loginPanel',//note I match the xtype region: 'north', height: 50 },
results in:Code:Ext.getCmp('loginPanel')
Ext.getCmp('loginPanel') has no propertiesMJ
API Search || Ext 3: docs-demo-upgrade guide || User Extension Repository
Frequently Asked Questions: FAQs
Tutorial: Grid (php/mysql/json) , Application Design and Structure || Extensions: MetaGrid, MessageWindow
-
2 Sep 2008 3:09 PM #2
By matching the id to the xtype you are restricted to one instance of that class...
And in your example Ext.getCmp() is looking for "'loginPanel'" instead of 'loginPanel' so it won't find it.
-
2 Sep 2008 5:05 PM #3
You are right, but that was just a typo making the forum post. I corrected that typo. Error still applies if you have an id and xtype that match. But not to get off topic, I was essentially interested if there was any convention for xtype naming of user extensions etc.
We're all using our own namespaces like good coders, but if we're sharing code in the community seems like there might be a good standard to go by so our xtypes don't get clobbered by others...or are easily intuitive, etc.MJ
API Search || Ext 3: docs-demo-upgrade guide || User Extension Repository
Frequently Asked Questions: FAQs
Tutorial: Grid (php/mysql/json) , Application Design and Structure || Extensions: MetaGrid, MessageWindow
-
3 Sep 2008 1:06 PM #4
I try to steer clear of using ids as much as possible, there are akin to global variables in my opinion. using getId() or itemId and getComponent does the job for me in virtually every scenario i come across.
in regards to xtype naming, the norm seems lowercase without word separation which is a bit contradictory to the class naming convention which seems to be captial for new words. although i think i recall looking in the code and seeing that teh xtype is actually formatted to lower case so it doesn't matter if you use capitals to separate words for xtype
and really xtype doesn't really have anyting to do with id, it is the name of the class / method being called - in your exmaple above it holds relavence, but when you think of a more generic type like xtype: 'panel' it does not seem so relevent


Reply With Quote
