Hi Benoît,
You could use the validate key instead of the check key. It allows you
to use a class member as validation function. You can then overwrite
that member in the child class:
qx.Class.define("ParentClass",
{
extend : qx.core.Object,
properties :
{
myProperty : {
nullable : false,
init : 0,
validate : "_checkMyProperty"
}
},
members :
{
_checkMyProperty : function(value)
{
if (value > 100) {
throw new Error("Invalid value! Must be below 100.");
}
}
}
});
qx.Class.define("ChildClass",
{
extend : ParentClass,
members :
{
_checkMyProperty : function(value)
{
if (value > 200) {
throw new Error("Invalid value! Must be below 200.");
}
}
}
});
The difference between "check" and "validate", is that the check
function is only kept in the source version, while the validate also
applies to the build version of your application.
If you want to keep the validate only in the source version, you could
wrap it within a if qx.core.Environment.get("qx.debug") {} statement,
which will be removed by the generator for build versions. But it's a
bit ugly. I would expect that the check key would also accept a member
as value, but it doesn't. Time for an enhancement bug, maybe?
Regards,
Marc
On 05/16/2011 10:36 AM, benco wrote:
> Hello,
>
> I'm currently trying to subclass an existing class and to overwrite an
> existing property to allow more possibilities. The "check" function of this
> property is a problem because I can't redefine it in the subclass.
>
> As it is impossible to completely and easily overwrite properties with qx
> class definitions, I was wondering how I could achieve doing it...
>
> By using a Mixin ? Via the "include" directive or by using a "patch" ? (I
> don't know if the include declaration in class definitions triggers also
> patching when there are existing methods). I tried these two ways but
> without success (the same check error occurs again).
>
> Any ideas ?
>
> Best,
>
> Benoît.
------------------------------------------------------------------------------
Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel