PDA

View Full Version : 2 to 3 migration : error "is not a constructor"



aimarsouris
25 Mar 2010, 9:49 AM
Hi,
I'm trying to migrate from 2.1 to 3.2 with a code I didn't write in the first place. I get this error from config.xtype=MyViewport:

types[config.xtype || defaultType] is not a constructor
return config.render ? con...config.xtype || defaultType](config); ext-all-debug.js (ligne 14553)

when using this code, which works well in previous version :



Ext.namespace("Ext.MyNameSpace");

Ext.MyNameSpace.Viewport = function(config) {
config = config || {};
Ext.apply(config,{
"layout":"border",
"items":[{
"id":"mainNorth",
"region":"north",
"height":32
}, {
"region":"center",
"xtype":"myChildType"
}]
});

Ext.MyNameSpace.myChildType.superclass.constructor.call(this,config);
}

Ext.extend(Ext.MyNameSpace.Viewport,Ext.Viewport, {

});

Ext.reg('MyViewport', Ext.MyNameSpace.Viewport);

I tried a few other codes (incl. example from API documentation) for the extension and always get the same error.

Thanks for helping.

25 Mar 2010, 10:01 AM
first, Ext.MyNameSpace.myChildType.superclass.constructor.call(this,config); is wrong


seconde, why are you adding to the Ext JS Namespace?! you should create your own

aimarsouris
26 Mar 2010, 6:09 AM
ok, I tried the code below in the two versions (2.2 and 3.2), the file is called layout.js.

An I still get the same error with release 3.2 and NOT with release 2.2.

Thanks


Ext.namespace("MySpace");

Ext.onReady(function(){
Ext.ComponentMgr.create({xtype:'myspaceviewport'})
});

MySpace.MySpaceViewport = function(config) {
config = config || {};
Ext.apply(config,{
"layout":"border",
"items":[{
"id":"mainNorth",
"region":"north",
"height":32
}, {
"region":"center",
"xtype":"myspacechildtype"
}]
});


MySpace.MySpaceViewport.superclass.constructor.call(this,config);
}

Ext.extend(MySpace.MySpaceViewport,Ext.Viewport, {

});

Ext.reg('myspaceviewport', MySpace.MySpaceViewport);



My two index.html are the following:

2.2 release:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<link rel="stylesheet" type="text/css" href="lib/ext-2.2.1/resources/css/ext-all.css" />
<link rel="stylesheet" type="text/css" href="lib/ext-2.2.1/resources/css/xtheme-slate.css" />

<!--Other css-->

</head>

<script type="text/javascript" src="lib/ext-2.2.1/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="lib/ext-2.2.1/adapter/ext/ext-base-debug.js"></script>
<script type="text/javascript" src="lib/ext-2.2.1/ext-core-debug.js"></script>
<script type="text/javascript" src="lib/ext-2.2.1/ext-all-debug.js"></script>

<!--Other scripts-->

<script type="text/javascript" src="js/layout.js"></script>
</html>


3.2 release:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<link rel="stylesheet" type="text/css" href="lib/ext-3.2-beta/resources/css/ext-all.css" />
<link rel="stylesheet" type="text/css" href="lib/ext-3.2-beta/resources/css/xtheme-gray.css" />

<!--Other css-->

</head>

<script type="text/javascript" src="lib/ext-3.2-beta/adapter/ext/ext-base-debug.js"></script>
<script type="text/javascript" src="lib/ext-3.2-beta/ext-all-debug.js"></script>

<!--Other scripts-->

<script type="text/javascript" src="js/layout.js"></script>
</html>

Animal
26 Mar 2010, 6:14 AM
Which constructor?

This is just a basic language error saying you are calling a function which is not defined.

Find out which one.

aimarsouris
26 Mar 2010, 6:18 AM
The constructor is "config : Object { xtype="myspaceviewport"}", that's why I don't understand.
Thanks

Animal
26 Mar 2010, 7:29 AM
Set it to break on all errors and see what it's actually doing!

aimarsouris
26 Mar 2010, 8:24 AM
Ok thanks Animal, I still have work to do...

Condor
26 Mar 2010, 8:29 AM
Where did you register xtype:'myspacechildtype'?

Animal
26 Mar 2010, 8:32 AM
Just a minute!

When would you ever be using an xtype of a Viewport? That's only for child Components in an items Array which a Viewport never can be!

And WHY would you subclass the Viewport class? There can be only one anyway!

aimarsouris
26 Mar 2010, 9:16 AM
I had some other issues that made my post irrelevant in the first place.
Thanks to Animal for his remark on subclassing a viewport.