PDA

View Full Version : Viewport, ref, alias, xtype confusion



bweiler
4 Dec 2011, 9:51 AM
I've been trying to figure out the twitter example and I am having trouble understanding how some of the pieces fit together. Here are my questions:

From Search.js:



refs: [
{
ref : 'main',
selector : 'mainview',
xtype : 'mainview',
autoCreate: true
},


* The selector and xtype are not explicitly defined in the Main.js container (aka. viewport). How is the selector in refs or xtype in refs used to identify the 'Twitter.view.Main' container?

* Why are selector and xtype both specified? Isn't only one of them needed?

* Is the alias property (widgets) of Containers used by refs in any way?

* If autoCreateViewport is used in the app definition, will autoCreate automatically put the mainview panel in the viewport?


Thanks,

Bruce

mitchellsimoens
5 Dec 2011, 10:52 AM
The selector is used with ComponentQuery to get the reference of that selector and cache it. The ref is for the name or the getter method that is automatically created, first character will be capitalized (in your example, 'main' will be transformed into 'getMain'). selector is ComponentQuery, if you have autoCreate set to true and there is no instance found, an instance will be created based on the xtype.

The alias property is definitely used. alias is a two part string, first is the type of alias and the second is the xtype which is used for ComponentQuery and instantiation.

autoCreate will only create an instance if there is not already an instance that matches the selector and if you execute the getter method that is created. So autoCreateViewport will create the Viewport class but in your controller you would have to call the getter method before the autoCreateViewport is executed to have a problem which isn't possible currently.

jiancha
30 Dec 2011, 10:16 AM
How is the xtype: mainview in refs used to identify the 'Twitter.view.Main' container?

this quest is still not answered yet, can you help us please ?