[Laszlo-user] Dataset as an Attribute and Tag Error

André Bargull a.bargull at intensis.de
Wed Dec 5 13:10:53 PST 2007


Hi David,

I definitely understand your confusion about the tree-datapath thing. 
It's about because "tree" resp. actually "basetree" tries to be 
super-smart, but it fails obviously. If you take a look at 
"basetree#createChildTrees()", you'll see a for-in loop which copies an 
internal object called "_instanceAttrs" into a new js-Object. All 
instance attributes of an instance are stored in this "_instanceAttrs" 
field, plus some special objects like a datapath (, if it was defined 
per datapath-tag!). And now we copy this field, because we want to make 
sure that every tree-node/leaf has got the same method, handlers, 
appearance etc. when we dynamically instantiate new trees-leafs.
Now comes the fun part: You've given your tree a datapath per tag, 
therefore the "_instanceAttrs"-object contains an entry called 
"$datapath". Later on in "basetree#createChildTrees()", the copy of 
"_instanceAttrs" (with the "$datapath" entry) will get another datapath, 
but this time attribute-like (identifier is "datapath" instead of 
"$datapath"). So, two datapaths for a tree => makes double replication, 
just as noted in the bugreport.

- André


On 12/5/2007 9:24 PM, David Buckler wrote:
> Andre
>
> I appreciate you opening up that bug and I understand it will definitely cover the datapath attribute versus child node issue.  I am just wondering does the datapath of the second tree get set by the first tree by the instantiation, and hence causes the duplicate replicaton.  I am just confused because all I did to get the duplicate replication was move the datapath attribute out of the tree tag into a child datapath tag with an xpath of *.  
>
> David
>
> -----Original Message-----
> From: André Bargull [mailto:andrebargull at googlemail.com] 
> Sent: Tuesday, December 04, 2007 4:05 PM
> To: David Buckler
> Cc: Henry Minsky
> Subject: Re: [Laszlo-user] Dataset as an Attribute and Tag Error
>
> I've created LPP-5193 (http://www.openlaszlo.org/jira/browse/LPP-5193)
> to fix this issue.
>
> - André
>
>
> On 12/4/2007 11:00 PM, André Bargull wrote:
>   
>> Hello David,
>>
>> I could reproduce this bug, so feel free to open a bugreport.
>>
>>     
>>> Here is an example using the tree code that is in the Laszlo Reference.
>>> You will note that all I did was pull the datapath attribute out of 
>>> the last tree node and used it as a tag.  When you run this code it creates
>>> duplicate nodes exactly as I first experienced.   Let me know if you are
>>> experiencing the same behavior I am and I have no problems opening up 
>>> a bug for this.
>>>  
>>> <canvas width="450" height="250">
>>>   <include href="lz/tree.lzx"/>
>>>  
>>>   <dataset name="ancestors">
>>>     <hobbit name="Frodo">
>>>       <hobbit name="Drogo">
>>>         <hobbit name="Fosco" grandparent="true"/>
>>>         <hobbit name="Bolger, Ruby" grandparent="true"/>
>>>       </hobbit>
>>>       <hobbit name="Brandybuck, Primula">
>>>         <hobbit name="Brandybuck, Gorbadoc" grandparent="true"/>
>>>         <hobbit name="Took, Mirabella" grandparent="true"/>
>>>       </hobbit>
>>>     </hobbit>
>>>   </dataset>
>>>  
>>>       <!-- data replicated tree -->
>>>     <view width="200" height="200">
>>>       <tree datapath="ancestors:/" icon="null" showroot="false">
>>>         <tree icon="null" text="$path{'@name'}"
>>> isleaf="$path{'@grandparent'}">
>>>           <datapath xpath="*"/>
>>>         </tree>
>>>       </tree>
>>>     </view>
>>>   </canvas>
>>>       


More information about the Laszlo-user mailing list