8 Replies Latest reply on Aug 27, 2008 7:34 PM by Newsgroup_User

    Tree selection bug?

    jpbouchard Level 1
      Hi,

      I don't know if this is a bug or not. When using XML as the data provider for the Tree component and multiple nodes have the same label, selecting anyone of the nodes will cause all of them to be selected. The problem stems from the fact that XML comparison is done by value. The comparison is dibe at line 6345 of ListBase. Is this a bug? If not, is there a known workaround?

      I attached code that reproduces the problem. Selecting the first node, selects the first, second and last node because, by value, they are all the same.

      Thanks!
      JPB
        • 1. Re: Tree selection bug?
          jpbouchard Level 1
          Actually, I just found a bug report concerning that. It is still open and there's a good workaround...

          http://bugs.adobe.com/jira/browse/SDK-12631
          • 2. Re: Tree selection bug?
            Level 7
            Switch to using a strongly typed object that implements IUID, or just make
            sure your XML has other identifying information to it. It's not really that
            helpful to have 19 "foos" in your list unless there is something else
            different about them.

            So, something like

            <mx:XMLList id="treeData">
            <node label="Test entry 1" id="1"/>
            <node label="Test entry 1" id="2"/>
            <node label="Test entry 2" id="3"/>
            <node label="Test entry 1" id="4"/>
            </mx:XMLList>

            HTH;

            Amy

            "jpbouchard" <webforumsuser@macromedia.com> wrote in message
            news:g941f3$1u8$1@forums.macromedia.com...
            > Hi,
            >
            > I don't know if this is a bug or not. When using XML as the data provider
            > for
            > the Tree component and multiple nodes have the same label, selecting
            > anyone of
            > the nodes will cause all of them to be selected. The problem stems from
            > the
            > fact that XML comparison is done by value. The comparison is dibe at line
            > 6345
            > of ListBase. Is this a bug? If not, is there a known workaround?
            >
            > I attached code that reproduces the problem. Selecting the first node,
            > selects
            > the first, second and last node because, by value, they are all the same.
            >
            > Thanks!
            > JPB
            >
            > <?xml version="1.0" encoding="utf-8"?>
            > <mx:VBox xmlns:mx=" http://www.adobe.com/2006/mxml" width="100%"
            > height="100%">
            > <mx:Script>
            > <![CDATA[
            > import mx.controls.Tree;
            >
            > private function selectFirst(): void {
            > myTree.selectedItem = treeData[0];
            > }
            >
            > ]]>
            > </mx:Script>
            >
            > <mx:XMLList id="treeData">
            > <node label="Test entry 1"/>
            > <node label="Test entry 1"/>
            > <node label="Test entry 2"/>
            > <node label="Test entry 1"/>
            > </mx:XMLList>
            >
            > <mx:Panel title="Tree Selection Bug" height="100%" width="100%"
            > paddingTop="10" paddingLeft="10" paddingRight="10" paddingBottom="10">
            > <mx:Button label="Select First" click="selectFirst()"/>
            > <mx:Tree id="myTree" width="100%" height="100%" labelField="@label"
            > showRoot="true" dataProvider="{treeData}"/>
            > </mx:Panel>
            >
            > </mx:VBox>
            >


            • 3. Re: Tree selection bug?
              jpbouchard Level 1
              Hi Amy,

              Thanks for the reply, I thought about using a different data provider, but I'm not sure if the ListBase supports it (from what I can tell from the setDataProvider() method in ListBase). I'll dig deeper.

              Also, to answer your question about the usefulness of having 19 foos. The problem occurs for child nodes as well so if you have something like that:

              <node label="bar"/>
              <node label="foo"/>
              <node label="baz">
              <node label="foo"/>
              </node>

              the problem will still occur and the 2 "foos" are unique, hierarchically wise.
              • 4. Re: Tree selection bug?
                jpbouchard Level 1
                I meant, ListBase supports other data provider but the only one that is hierarchical is XMLListCollection...
                • 5. Re: Tree selection bug?
                  Level 7

                  "jpbouchard" <webforumsuser@macromedia.com> wrote in message
                  news:g9470m$8uv$1@forums.macromedia.com...
                  >I meant, ListBase supports other data provider but the only one that is
                  >hierarchical is XMLListCollection...

                  HeirarchicalData, HierarchicalCollectionView


                  • 6. Re: Tree selection bug?
                    Level 7

                    "jpbouchard" <webforumsuser@macromedia.com> wrote in message
                    news:g946ug$8s8$1@forums.macromedia.com...
                    > Hi Amy,
                    >
                    > Thanks for the reply, I thought about using a different data provider, but
                    > I'm
                    > not sure if the ListBase supports it (from what I can tell from the
                    > setDataProvider() method in ListBase). I'll dig deeper.
                    >
                    > Also, to answer your question about the usefulness of having 19 foos. The
                    > problem occurs for child nodes as well so if you have something like that:
                    >
                    > <node label="bar"/>
                    > <node label="foo"/>
                    > <node label="baz">
                    > <node label="foo"/>
                    > </node>
                    >
                    > the problem will still occur and the 2 "foos" are unique, hierarchically
                    > wise.

                    The point is, that if there's nothing different between the two of them,
                    then what is the point of having two of them or selecting one vs. the other?


                    • 7. Re: Tree selection bug?
                      jpbouchard Level 1
                      But there is something different, one foo is under baz, the other one is at the root of the hierarchy. Think of it as a filesystem, you may have many files named document.txt, but under different directories...
                      • 8. Re: Tree selection bug?
                        Level 7

                        "jpbouchard" <jp.bouchard@axale.com> wrote in message
                        news:g94fqm$kbl$1@forums.macromedia.com...
                        > But there is something different, one foo is under baz, the other one is
                        > at the
                        > root of the hierarchy. Think of it as a filesystem, you may have many
                        > files
                        > named document.txt, but under different directories...

                        And each of those will have something different about it, whether it is the
                        creation date, the contents, etc. Regardless, when you select a node, what
                        you get back is...the node. So if there's nothing that is different between
                        the two nodes, what's the point?

                        For more on this:

                        http://flexdiary.blogspot.com/2008/07/musings-on-advanceddatagrid-part-5_03.html