-
17 Oct 2011 3:49 PM #1
Unanswered: any replacement for Ext.reg() ? I prefered that to using aliases
Unanswered: any replacement for Ext.reg() ? I prefered that to using aliases
My project has over 200 views.. and most views are duplicated in their naming because there is a landscape and a portrait view for each.
Previously I was able to use the Ext.Reg() to register my custom class using it's full name.
For example I would create a new class
app.view.containers.landscape.carousel.UnicornAndRainbows = Ext.extend(Ext.Panel, {
...
});
and at the bottom I would add this:
Ext.reg('app.view.containers.landscape.carousel.UnicornAndRainbows', Wicked.view.containers.landscape.carousel.MoviesRelatedScenes);
Which allowed me to use
xtype: "app.view.containers.landscape.carousel.UnicornAndRainbows",
when I wanted to use it.. which I found VERY convenient because it's clear even if a bit lengthy
Now... it looks like Ext.reg is deprecated? So I have to use an alias "alias: 'widget.myAlias'" and then use "myAlias" when I want to use my xtype. This is inconvenient because it means I have to create new names for all of my 200+ views. I can't just use my class name "UnicornAndRainbows" because then it will conflict with the class of the same name in my portrait views... you understand?
I use both app.view.containers.landscape.carousel.UnicornAndRainbows and app.view.containers.portrait.carousel.UnicornAndRainbows
In fact in some cases I also use app.view.containers.landscape.panel.UnicornAndRainbows
I really liked being able to use the full class name when refering to it and not some shortened alias... any solution?
I'm sorry if I use the wrong terms sometimes... I've only been working with Sencha Touch for 2 months (full time 40 hours per week) and I'm still confused about a lot of things.
-
18 Oct 2011 6:21 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,656
- Vote Rating
- 435
- Answers
- 3108
What's wrong with using the alias config? There is also the xtype config.
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
18 Oct 2011 6:34 AM #3
I think I clearly explained what's my gripe with it.. but to sum it up.. I prefered Ext.reg() because I could use the SAME name as my class' name
Whereas now... I have to make up a NEW identifier... with 200 classes.. that's 200 new identifies that I need to remember.. which is very inconvenient.
The code above is not valid.. I get a "invalid unique id of object" error if I try to do this. That means that when creating a new instance of my class or inserting it in one of my components.. I can't use the full class name to refer to it. Before I couldCode:Ext.define('app.view.containers.landscape.Master', { extend: 'Ext.Container', alias : "widget.app.view.containers.landscape.Master", xtype : "app.view.containers.landscape.Master",
Before I could go
items: [{
xtype: "app.view.containers.landscape.Master",
}]
but now I have to set up a different alias (without periods in the name) for each of my classes and that is VERY inconvenient.
So... is there any way around this so I can use my class full name when refering to it instead of a shortened alias/xtype config?
-
18 Oct 2011 6:57 AM #4Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,656
- Vote Rating
- 435
- Answers
- 3108
That has nothing to do with alias or xtype or even if Ext.reg would have been kept... ComponentQuery will not work with an xtype with periods.
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
18 Oct 2011 7:01 AM #5
oh ok
well all I know is that with ST 1.0 and 1.1 it did work. I use the full class name (with periods) to create all my components and it works... now it doesn't work anymore and that makes me sad
-
18 Oct 2011 7:04 AM #6Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,656
- Vote Rating
- 435
- Answers
- 3108
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
18 Oct 2011 7:12 AM #7
anyway... I guess I just found a way to get around the problem.
I simply created a custom function that strips the periods, it's not pretty but it works and saves me loads of work
Code:Ext.define('myApp.view.containers.landscape.Master', { extend: 'Ext.Container', xtype : xtype("myApp.view.containers.landscape.Master"),Code:items: [ { xtype: xtype('myApp.view.containers.landscape.Master'), }, ],Code:function xtype(str) { return str.replace(/\./g, ""); }
-
18 Oct 2011 7:45 AM #8Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- Frederick MD, NYC, DC
- Posts
- 16,169
- Vote Rating
- 28
- Answers
- 83

Jay Garcia @ModusJesus || Modus Create co-founder
Ext JS in Action author
Sencha Touch in Action author
Get in touch for Ext JS & Sencha Touch Touch Training
We are also working on Video-based Sencha Touch training: Check it out here.



Reply With Quote
I agree that Xtypes for complex apps should be named after the class, but your approach s not clean, IMHO.