-
3 Feb 2010 11:48 AM #1
Extendable Class Pattern
Extendable Class Pattern
I have an increasing number of forms which seem to be sharing common code.
So my question is, is there a pattern for creating a base form of some type in ExtJS which can be extended.Code:FormA = function() { // Here are common variables var msgBus = undefined; var formRecord= undefined; // This stuff is specific to each form var formPanel = new Ext.FormPanel({ frame : true, labelAlign : 'right', etc ..... } // Here are some common functions function formUpdate() { .... } return { ......
My thinking is either build a class extending Observable or create a generic Javascript object prototype.
In Java (sorry I understand Java better than jscript) I would just create a base class and extend;
class BaseClass{}
class FormA extends BaseClass{}
class FormB extends BaseClass{}
What is the best approach that is flexible enough?
Thanks, Len
-
3 Feb 2010 2:01 PM #2
You can do the same:
Code:BaseClass = Ext.extend(Object, { constructor : function(){ //do stuff }, method1 : function(){ } }); SubClass = Ext.extend(BaseClass, { constructor : function(){ SubClass.superclass.constructor.call(this); this.method1(); } });Evan Trimboli
Sencha Developer
Twitter - @evantrimboli
Don't be afraid of the source code!
-
3 Feb 2010 2:27 PM #3


Reply With Quote