3.0.0

BUG in Model definition : Alex ?

Alex,

Having spent a week working out the code, I think there may be a bug in the definiton of a model (from a control) and the subsequent setting of a a model property to be an array of values.

I posted more information here: http://www.activewidgets.com/javascript.forum.12190.1/stange-model-behaviour-help-please.html

but, basically if I have initialised my model property to be a primitive type say "" or 0 , then if I susequently assign a array to the property {"0","1","2","3"} then when I call getXProperty I always get the original primitive value returned.

Looking at the code for setting a proptery I can see that it is trying to handle the setting of various types of objects to a property (_X, _X1, _X2, _X3 in the control object) definitions based on the provide value tyope (an object (function), an array, a primitive etc).

When the dynamic getter is called for the property it seems to be checking each declaration type ( _X1, _X2, _X3) to see if is set and then return the value assigned.

But because the primitive value (_X) is not deleted during declaration the getXProperty code never gets the desired value (_X1 the array value) to return.

Phew !!

I hope that is all clear. My apologies for bothering you with this Alex (or anyone else!!) but I think this bug (if thats what it is) is failry serious and debilitating in terms of writing your own widgets, where you need to set your own model.

If anyone wants my code to check it for themselves, please do shout !!


Yasdnil
February 24,
Alex,

Futher to my post, in the setProp method in system/control.js where you assign the array value to the property _p1, should it not also delete this[_p] if a primative types has previously been defined for a property ( as time of model definition) ?

around line 190

this[_p1] = v;
delete this[_p2];
delete this[_p3];

delete this[_p1]; ???????
Yasdnil
February 24,
Problem solved!!!!

Dont initialise modesl with array primitives - set them explictly.
So:

obj.defineModel("panel", {count:0, heading: [], items: []});

becomes :

obj.defineModel("panel", {count:0});
obj.definePanelProperty("headings", [], true);
obj.definePanelProperty("items", [], true);

and when your template calls getPanelHeadings it returns the array of initialised variables!!

Gotcha of the century this one :)
Yasdnil
February 24,
Thanks for posting your findings, this is good information for everyone to know.
Jim Hunter (www.FriendsOfAW.com)
February 27,

This topic is archived.

See also:


Back to support forum

Search

Version 2

Looking for AW 2.6 ?
The old site is here.