Yes, there is a way to 'patch' an existing method with your new method. And
there is a way to get access to the superclass version of the method. I have
not done either of these but I did read about them in the document "Proposed
Class Declarations for qooxdoo 0.7". It has all the new features shown
there. It's a good starting point to learn the new methods.
Jim
On 3/1/07, Dietrich Streifert <[EMAIL PROTECTED]> wrote:
Thank you Jim.
That sounds promising. I also used to extend qx.ui.core.Widget with my own
set of properties by using the qx.Proto = ..classname.. syntax.
One more question left ;-)
Is it possible to "overwrite" or redeclare a method of a class by using
mixins? If yes: do I have access to the original method of the class?
Something like:
theMethod: function(arg) {
doSomethingWithArg(arg);
hookToOldMethod.theMethod(arg);
}
The typical usage would be to add some code to the method and then call
the original method.
Jim Hunter schrieb:
First, yes, all objects that decend from qx.core.Object will get the new
property. That is why I am doing it, to add a property to all objects so
that I can have access to it. For subclassed classes that subclass from a
class with mixins, those classes should also inherit the mixin items. From
previous testing, prior to .7, if you add new properties high enough up
that
chain then all classes inheriting from it will contain your mixins and if
a
later class has a declaration for the same named property or method then
that new method takes precedence . I use this to my advantage. The method
hasChildren is on 'most' objects but not all. I needed to be able to call
this on ALL objects so I created a stub function at the Object level to
return false as a default. Subordinent classes that declare their own
hasChildren will overwrite my function and return the correct answer. It
works quite well.
Jim
On 2/28/07, Dietrich Streifert <[EMAIL PROTECTED]><[EMAIL PROTECTED]>wrote:
Hi Fabian
will all subclasses derived from a superclass which has a mixin inherit
the mixed in attributes?
So in the example below: will all classes which are derived from
qx.core.Object inherit the property mID?
If a conflict exists eg. there is already a property named myID defined in
the unmixed class, will the mixin overwrite the existing property?
Is this also true for methods?
Fabian Jakobs schrieb:
Hello Jim
With the new Clazz way of doing things, what is the new and preferred
way to add functionality to existing qooxdoo classes? Previously, my
old code might look like this:
qx.Proto = qx.OO.classes["qx.core.Object "].prototype;
qx.OO.addProperty({ name: "myID", type: "string", defaultValue: ""});
but this doesn't pass the build process for .7 so what is the
preferred way to do this now? I have read through the new docs but
didn't see this mentioned.
The supported way to extend existing classes is to use Mixins. You can
define a mixin for your extension and include it to an existing class
using qx.Clazz.include
Example:
qx.Mixin.define("custom.MObject",
{
properties : {
myID : {
type: "string",
defaultValue: "",
_legacy: true
}
}
});
qx.Clazz.include(qx.core.Object, custom.MObject");
If you want to overwrite existing methods/properties you can use
qx.Clazz.patch instead but we hope this is never needed because changing
the imlpementation is always risky and may break code.
Best Fabian
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share
your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
qooxdoo-devel mailing list
[EMAIL PROTECTED]://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
--
Mit freundlichen Grüßen
Dietrich Streifert
--
Visionet GmbH
Firmensitz: Am Weichselgarten 7, 91058 Erlangen
Registergericht: Handelsregister Fürth, HRB 6573
Geschäftsführer: Stefan Lindner
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share
your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
------------------------------
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
------------------------------
_______________________________________________
qooxdoo-devel mailing list
[EMAIL PROTECTED]://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
--
Mit freundlichen Grüßen
Dietrich Streifert
--
Visionet GmbH
Firmensitz: Am Weichselgarten 7, 91058 Erlangen
Registergericht: Handelsregister Fürth, HRB 6573
Geschäftsführer: Stefan Lindner
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share
your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel