Results 1 to 2 of 2

Thread: Inheritance Problem

  1. #1
    Ext User
    Join Date
    Mar 2007
    Location
    United Kingdom
    Posts
    11
    Vote Rating
    0
      0  

    Default 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 User hendricd's Avatar
    Join Date
    Aug 2007
    Location
    Long Island, NY USA
    Posts
    5,966
    Vote Rating
    15
      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.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •