3.2.0

Has patching mechanism changed with AW 2.0 ?

Hello,
Based on paging1.js patch for AW 1.0, I tried the following with AW 2.0:

MyClass = {};
MyClass.Page = AW.System.Model.subclass();
MyClass.Page.create = function()
{
var obj = this.prototype;
obj.defineProperty("test", "test");
}
MyClass.Page.create();

But I have the following error:

obj.defineProperty is not a function

If I execute the same code (by replacing of course "AW" with "Active") with AW 1.0, it work fine.
Could someone please tell me why?
Thanks in advance for your help!
Livio
July 21,
var MyClass = {};
MyClass.Page = AW.System.Model.subclass();
MyClass.Page.create = function()
{
var obj = this.prototype;
obj.defineProperty("test", "test");
}
//MyClass.create();
var test1 = new MyClass.Page;
alert( test1.getTest() );
July 21,
Yes, the class.create() method call is deferred in 2.5 (and 2.0) until the first instance of that class is created. You should not call create() method explicitly like in 1.0, it is called automatically by the object constuctor after creating the parent classes.

It means that the MyClass.Page.prototype might not have any methods until the first instance of this or parent class is created. So if you want to patch the class - first create an object to make sure that all classes in the prototype chain are created and initialized -

new AW.ExistingClass; // create/initialize this and parent classes
AW.ExistingClass.prototype.oldMethod = newImplementation;
Alex (ActiveWidgets)
July 21,
Ok, thank you very much for your detailed answers!
Livio
July 22,

This topic is archived.

See also:


Back to support forum