mjessup
03-06-2009, 11:17 AM
I have data which is being shared across a couple of views using lazy replication. I have deduced that (with the way I am doing it) the selection manager has problems when a node of data is being replicated in two places. Some example code:
<canvas debug="true" width="100%" height="400">
<simplelayout axis="y" />
<view>
<simplelayout axis="x" />
<list id="list1" multiselect="true" dataoption="lazy" width="200" height="200">
<textlistitem name="item" text="$path{'@txt'}">
<datapath replication="lazy" />
</textlistitem>
</list>
<list id="list2" multiselect="true" dataoption="lazy" width="200" height="200">
<textlistitem name="item" text="$path{'@txt'}">
<datapath replication="lazy" />
</textlistitem>
</list>
</view>
<button text="Change">
<handler name="onclick"><![CDATA[
var d = new Array();
for(var i=d.length;i<20;i++)
d.push(new LzDataElement('Node',
{'txt': 'item '+Math.random()}));
list1.item.datapath.setNodes(d);
list2.item.datapath.setNodes(d.slice(10));
]]></handler>
</button>
</canvas>
To replicate the problem click the button to populate the lists with some data. Note it creates 20 elements, all of which go to list 1 and the last 10 of which go to list 2 (done to prove that passing the same/a different array to the datapath isn't the problem). Now two ways in which the selection manager "fails". First select any item in list 2, now scroll down in list 1 and you will see it is selected (not necessarily bad, but unexpected, plus no onselect fired by list 1). Now select an item in list 1 also appearing in list 2 which you can see. Note the item in list 2 is not selected. Attempt to select the item in list 2 and it will "refuse" to be selected (though if you shift-select it will). And if you then unselect list 2, list 1 remains selected, which may be desired, but is inconsistent with the first example.
So my question is as follows. Is there a way in which the same data elements can be shared by different objects using lazy replication and have the selection manager behave as I expect (treating each replicated item independently), or at least in a consistent manner (i.e. selecting/deselecting all replicated views attached to the same data node). I looked around and the closest thing I found sounded like I may need to override the selection manager of the lists? I also checked JIRA but didn't notice anything similar to this, so not sure if I may have discovered a new bug.
I am doing this using LPS4.1.1 and the problem occurs both in SWF8 and DHTML.
<canvas debug="true" width="100%" height="400">
<simplelayout axis="y" />
<view>
<simplelayout axis="x" />
<list id="list1" multiselect="true" dataoption="lazy" width="200" height="200">
<textlistitem name="item" text="$path{'@txt'}">
<datapath replication="lazy" />
</textlistitem>
</list>
<list id="list2" multiselect="true" dataoption="lazy" width="200" height="200">
<textlistitem name="item" text="$path{'@txt'}">
<datapath replication="lazy" />
</textlistitem>
</list>
</view>
<button text="Change">
<handler name="onclick"><![CDATA[
var d = new Array();
for(var i=d.length;i<20;i++)
d.push(new LzDataElement('Node',
{'txt': 'item '+Math.random()}));
list1.item.datapath.setNodes(d);
list2.item.datapath.setNodes(d.slice(10));
]]></handler>
</button>
</canvas>
To replicate the problem click the button to populate the lists with some data. Note it creates 20 elements, all of which go to list 1 and the last 10 of which go to list 2 (done to prove that passing the same/a different array to the datapath isn't the problem). Now two ways in which the selection manager "fails". First select any item in list 2, now scroll down in list 1 and you will see it is selected (not necessarily bad, but unexpected, plus no onselect fired by list 1). Now select an item in list 1 also appearing in list 2 which you can see. Note the item in list 2 is not selected. Attempt to select the item in list 2 and it will "refuse" to be selected (though if you shift-select it will). And if you then unselect list 2, list 1 remains selected, which may be desired, but is inconsistent with the first example.
So my question is as follows. Is there a way in which the same data elements can be shared by different objects using lazy replication and have the selection manager behave as I expect (treating each replicated item independently), or at least in a consistent manner (i.e. selecting/deselecting all replicated views attached to the same data node). I looked around and the closest thing I found sounded like I may need to override the selection manager of the lists? I also checked JIRA but didn't notice anything similar to this, so not sure if I may have discovered a new bug.
I am doing this using LPS4.1.1 and the problem occurs both in SWF8 and DHTML.