BaseForm:
1 /** 2 * 基本表单类 3 */ 4 Ext.define("Lms.view.BaseForm", { 5 extend : "Ext.form.Panel", 6 alias : "widget.baseform", 7 bodyPadding : '10 20 10 10', 8 border : false, 9 layout : "form",// 默认 10 waitMsg : "请稍等...", 11 waitTitle : '提示', 12 autoScroll : true, 13 defaults : { 14 xtype : 'textfield', 15 labelAlign : 'left', 16 width : 150, 17 labelWidth : "70", 18 labelSeparator : "", 19 allowBlank : false, 20 blankText : "该值不能为空", 21 msgTarget : "qtip" 22 }, 23 tbar : [{ 24 xtype : "button", 25 text : "返回", 26 ref : "btnBack", 27 iconCls : "icon_form_back" 28 }], 29 buttons : [{ 30 text : "提交", 31 ref : "btnSubmit", 32 iconCls : "icon_form_submit" 33 }, { 34 text : "重置", 35 ref : "btnReset", 36 iconCls : "icon_form_reset" 37 }], 38 initComponent : function() { 39 this.callParent(arguments); 40 } 41 });
BaseFormController:
1 Ext.define("Lms.controller.BaseFormController", { 2 extend : "Ext.app.Controller", 3 init : function() { 4 this.control({
ChatRoomForm:继承于BaseForm时BaseForm里面带的事件就已经带有了,不再需要controller在继承
1 /* 2 * 聊天面板 3 */ 4 Ext.define('Lms.person.view.ChatRoomForm', { 5 extend : 'Lms.view.BaseForm', 6 alias : 'widget.chatroom', 7 tbar : null, 8 items : [{ 9 fieldLabel : "资源名", 10 name : "name" 11 }], 12 buttons : [{ 13 xtype : "textfield", 14 width : 500 15 }, { 16 text : "发送", 17 ref : "btnSend", 18 iconCls : "icon_form_submit" 19 }], 20 initComponent : function() { 21 this.callParent(arguments); 22 } 23 });
ChatFormController:
1 /** 2 * 聊天室控制类 3 */ 4 Ext.define("Lms.person.controller.ChatController", { 5 extend : "Ext.app.Controller", // 这里不需要继承BaseController,因为界面继承时就已经带有事件了 6 init : function() { 7 var flag = comm.get("ChatController"); 8 if (!flag) { // 避免事件重复注册 9 this.control({ 10 "chatroom button[ref=btnSend]" : { 11 click : function(btn) { 12 Ext.example.msg("系统消息", "发送成功"); 13 } 14 } 15 }); 16 } 17 comm.add("ChatController", true); 18 this.callParent(arguments); 19 },