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

推荐订阅源

H
Hackread – Cybersecurity News, Data Breaches, AI and More
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
V
V2EX
T
The Blog of Author Tim Ferriss
腾讯CDC
Hugging Face - Blog
Hugging Face - Blog
雷峰网
雷峰网
爱范儿
爱范儿
GbyAI
GbyAI
H
Help Net Security
I
InfoQ
罗磊的独立博客
酷 壳 – CoolShell
酷 壳 – CoolShell
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
人人都是产品经理
人人都是产品经理
J
Java Code Geeks
Microsoft Security Blog
Microsoft Security Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
N
Netflix TechBlog - Medium
Last Week in AI
Last Week in AI
宝玉的分享
宝玉的分享
云风的 BLOG
云风的 BLOG
Project Zero
Project Zero
P
Privacy & Cybersecurity Law Blog
A
Arctic Wolf
Know Your Adversary
Know Your Adversary
G
Google Developers Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
T
Tor Project blog
V
Vulnerabilities – Threatpost
Y
Y Combinator Blog
WordPress大学
WordPress大学
V
Visual Studio Blog
博客园_首页
G
GRAHAM CLULEY
K
Kaspersky official blog
T
Tailwind CSS Blog
T
Threat Research - Cisco Blogs
博客园 - Franky
D
Docker
Security Latest
Security Latest
I
Intezer
有赞技术团队
有赞技术团队
Application and Cybersecurity Blog
Application and Cybersecurity Blog
博客园 - 【当耐特】
B
Blog RSS Feed
T
The Exploit Database - CXSecurity.com
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻

博客园 - 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有所帮助