惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

A
Arctic Wolf
博客园 - 聂微东
F
Fortinet All Blogs
云风的 BLOG
云风的 BLOG
小众软件
小众软件
V
Visual Studio Blog
博客园 - 三生石上(FineUI控件)
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Apple Machine Learning Research
Apple Machine Learning Research
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
The Cloudflare Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
The GitHub Blog
The GitHub Blog
Y
Y Combinator Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园_首页
L
LangChain Blog
A
About on SuperTechFans
阮一峰的网络日志
阮一峰的网络日志
I
Intezer
T
The Blog of Author Tim Ferriss
Security Latest
Security Latest
C
CXSECURITY Database RSS Feed - CXSecurity.com
Know Your Adversary
Know Your Adversary
Simon Willison's Weblog
Simon Willison's Weblog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
P
Palo Alto Networks Blog
Scott Helme
Scott Helme
S
Secure Thoughts
Spread Privacy
Spread Privacy
T
Threat Research - Cisco Blogs
Attack and Defense Labs
Attack and Defense Labs
P
Privacy & Cybersecurity Law Blog
O
OpenAI News
H
Heimdal Security Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Help Net Security
Help Net Security
C
Cyber Attacks, Cyber Crime and Cyber Security
Blog — PlanetScale
Blog — PlanetScale
GbyAI
GbyAI
G
Google Developers Blog
博客园 - Franky
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
K
Kaspersky official blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
T
Tor Project blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
T
Tenable Blog
Google Online Security Blog
Google Online Security Blog
PCI Perspectives
PCI Perspectives

博客园 - YFeng_Lee

webHttpBinding+wsHttpBinding+basicHttpBinding的区别 (转) AppDomain对于静态对象的独享引用 AppDomain 详解(转) .net工具 InstallShield12 添加自定义对话框,并根据输入值修改对应的Config文件。 普通管理类程序开发之难度系数、层次之说法(转自csdn) 待阅读书目 C#开发Windows Service程序 创建一个windows service应用程序 Ext简介(转) XML与数据库 分析模式 - 责任模式 NHibernate Cascades: the different between all, all-delete-orphans and save-update 企业开发框架NHibernate和Spring.Net简介-4 企业开发框架NHibernate和Spring.Net简介-3 企业开发框架NHibernate和Spring.Net简介-2 企业开发框架NHibernate和Spring.Net简介-1 Nhibernate学习之many-to-many篇(转 明了篇) Nhibernate学习起步之many-to-one篇(转 明了篇)
Ext的组件结构分析(转)
YFeng_Lee · 2009-03-11 · via 博客园 - YFeng_Lee

相信大家看了Ext2.0后, 印象最深的应该是Ext的组件模式,很好的规范了组件设计,用Manager的统一管理,也是很好的方式.下面简单分析一下Ext的组件结构.

Ext的所有组件都是扩展于Ext.Component, 而后子类扩展和集成形成了一个单根的组件树.
Ext中使用组件的方式很不一样,可以看一个例子.

js 代码

  1. var formPanel = new Ext.form.FormPanel({
  2. items: [{
  3. xtype: 'hidden',
  4. name: 'domainId'
  5. },{
  6. fieldLabel: '姓名',
  7. name: 'name',
  8. allowBlank:false
  9. },{
  10. fieldLabel: '权限',
  11. xtype: 'combo',
  12. name: 'auth'
  13. },{
  14. fieldLabel: '帐号',
  15. name: 'account'
  16. },{
  17. fieldLabel: 'Email',
  18. name: 'email',
  19. vtype:'email'
  20. },{
  21. fieldLabel: '启用',
  22. xtype: 'checkbox',
  23. name: 'enabled'
  24. }
  25. ]
  26. });

如此这样就能实现一个包含了很多元素的表单, items里面定义了表单要显示的输入框等组件,但是items里面仅仅是简单的json对象,怎么能显示出来各种不同的表单元素呢?

我们注意到items的每一个元素几乎都有一个xtype属性,这个xtype属性就是描述组件类的关键.

其实Ext里面的组件(Panel, Form Datepicker等等), 在定义完Class之后, 都会把自己注册到Ext.ComponentMgr里面. 简单看一个box的组件, 在BoxComponent.js文件的最后一行可以看到:

js 代码

  1. Ext.reg('box', Ext.BoxComponent);

而在, ComponentMgr.js文件里

js 代码

  1. registerType : function(xtype, cls){
  2. types[xtype] = cls;
  3. cls.xtype = xtype;
  4. },
  5. create : function(config, defaultType){
  6. return new types[config.xtype || defaultType](config);
  7. }
  8. };
  9. }();
  10. Ext.reg = Ext.ComponentMgr.registerType;

其实是执行了registerType 这个方法,方法很简单, 把xtype这个名字和对应的cls放到types里面, 而后看到create 我们应该会明白了, 以后想创建组件的时候,就调用 create({xtype: 'box'}) 就OK了

那么我们看看items里面的元素是怎么创建的吧, form的继承树中有一个Ext.Container类, 恩,就在这个类里呢:

js 代码

  1. lookupComponent : function(comp){
  2. if(typeof comp == 'string'){
  3. return Ext.ComponentMgr.get(comp);
  4. }else if(!comp.events){
  5. return this.createComponent(comp);
  6. }
  7. return comp;
  8. },
  9. createComponent : function(config){
  10. return Ext.ComponentMgr.create(config, this.defaultType);
  11. },

恩,基本就是这样了, 希望对大家理解Ext有所帮助