1. #1
    Ext User
    Join Date
    Mar 2007
    Location
    United Kingdom
    Posts
    11
    Vote Rating
    0
    deltafoxtrot is on a distinguished road

      0  

    Default Inheritance Problem

    Inheritance Problem


    Please have a look at the small code snippet below. In this case, I'm using Ext.extend to allow xx.widgets.ImageManagementPage to inherit properties and methods from xx.widgets.BasePage. However, xx.widgets.ImageManagementPage appears to inherit neither the properties nor the method. The alert in xx.widgets.ImageManagementPage.render lists these props as undefined. This post is related to http://extjs.com/forum/showthread.php?p=167261. Any help would be greatly appreciated.

    Code:
    xx.widgets.BasePage = function() {
    	return {
    		el : null,
    		portalId : 0,
    		rendered : false,
    		render : function() {
    			throw new xx.widgets.MethodNotImplementedError();
    		}
    	}
    };
    
    xx.widgets.ImageManagementPage = function(el, portalId) {
    	xx.widgets.ImageManagementPage.superclass.constructor.call(this, {
    		el : el,
    		portalId : portalId
    	});
    };
    Ext.extend(xx.widgets.ImageManagementPage, xx.widgets.BasePage, {
    	render : function() {
    		alert('el='+this.el+', portalId='+this.portalId);
    		this.rendered=true;
    	}
    });

  2. #2
    Sencha - Community Support Team hendricd's Avatar
    Join Date
    Aug 2007
    Location
    Long Island, NY USA
    Posts
    5,963
    Vote Rating
    10
    hendricd will become famous soon enough hendricd will become famous soon enough

      0  

    Default


    @deltafoxtrot-- Class inheritance in Ext is based on Function.prototypes. Try that this way:

    Code:
    xx.widgets.BasePage = function() {}  //Create an abstract base class
    Ext.apply( xx.widgets.BasePage.prototype,  {
            el : null,
            portalId : 0,
            rendered : false,
            render : function() {
                throw new xx.widgets.MethodNotImplementedError();
            }
        }
    });
    
    xx.widgets.ImageManagementPage = function(el, portalId) {
        xx.widgets.ImageManagementPage.superclass.constructor.call(this, {
            el : el,
            portalId : portalId
        });
    };
    Ext.extend(xx.widgets.ImageManagementPage, xx.widgets.BasePage, {
        render : function() {
            alert('el='+this.el+', portalId='+this.portalId);
            this.rendered=true;
        }
    });
    "be dom-ready..."
    Doug Hendricks

    Maintaining ux: ManagedIFrame, MIF2 (FAQ, Wiki), ux.Media/Flash, AudioEvents, ux.Chart[Fusion,OFC,amChart], ext-basex.js/$JIT, Documentation Site.


    Got Sencha licensing questions? Find out more here.


Thread Participants: 1