Hi,
this won´t work, because die constructor function is added with a constant key
to the class definition javascript object created by qooxdoo. So the second one
wins because the first one will be redefined (because they got the same key:
'construct').
Overloading of functions by parameter lists (like it´s possible in C++) will
not work in javascript and is not supported by the qooxdoo OO-layer.
The simulate the desired behavior you could check if variables are undefined:
construct: function(id, description, subCategories, category){
this.base(arguments);
this.setId(id);
alert("bla");
if (description !== undefined) {
this.setDescription(description);
}...
},
Cheers,
Rob.
Mit freundlichen Grüßen / Best regards
Dipl.-Inf. (FH) Robert Nimax
Geschäftsbereich Inventory & Supply Chain
INFORM GmbH, Pascalstraße 23, 52076 Aachen, Germany
Telefon: (+49) 2408 9456-1700, Fax: (+49) 2408 9456-1750
E-Mail: [email protected], Web: http://www.inform-software.com
INFORM Institut für Operations Research und Management GmbH
Registered AmtsG Aachen HRB1144 Gfhr. Adrian Weiler
-----Ursprüngliche Nachricht-----
Von: chrjab [mailto:[email protected]]
Gesendet: Dienstag, 24. Januar 2012 09:55
An: Robert Nimax; [email protected]
Betreff: [qooxdoo-devel] Two or more constructors
Hi,
I tried to define two constructors in a class, but when I create an object, the
second constructor is always called.
Example:
qx.Class.define("webshop.classes.business.Category",
{
extend: qx.core.Object,
properties: {
id: { init: null, check: "String" },
description: { init: null, check: "String" },
subCategories: { init: null, check: "qx.data.Array" },
category: { init: null, check: "webshop.classes.business.Category" }
},
construct: function(id){
this.base(arguments);
this.setId(id);
},
construct: function(id, description, subCategories, category){
this.base(arguments);
this.setId(id);
alert("bla");
this.setDescription(description);
this.setSubCategories(subCategories);
this.setCategory(category);
},
members :
{
}
});
I try to create an object like this:
var category = new webshop.classes.business.Category("1");
This calls the second constructor, although I use only one parameter. What's
wrong? Is it not possible to use two constructors? Didn't find an example for
this.
--
View this message in context:
http://qooxdoo.678.n2.nabble.com/Two-or-more-constructors-tp7219626p7219626.html
Sent from the qooxdoo mailing list archive at Nabble.com.
------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers is just
$99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style
Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel