3 Replies Latest reply on Aug 18, 2012 6:52 AM by omidbiz

    Tree Drag and Drop Problem with recursiveNodesAdapter

    skarvenz

      I have a tree that contains both a recursiveTreeNodesAdapter and treeNodesAdapter. When I perform a drag and drop onto the tree itself, nodes that are dragged from the treeNodesAdapter will reRender the tree, but nodes that are dragged from the recursiveTreeNodesAdapter do not seem to reRender the tree. It seems to be the same problem as bug RF-1801 (https://jira.jboss.org/jira/browse/RF-1081) but it is only happening when the node being dragged is from the recursiveTreeNodesAdapter. I have tried reRendering the entire panel that the tree is on, but that doesn't seem to work either. Please see code below.

      Is anyone else having this problem? or have a workaround for it?
      Thanks!

      JSP Page:
      <rich:tree adviseNodeOpened="#{ui$query$setFilters.adviseNodeOpen}" icon="" iconLeaf="" showConnectingLines="true" switchType="ajax" id="theTree" nodeSelectListener="#{ui$query$setFilters.processTreeSelection}"
      reRender="theTree" dropListener="#{ui$query$setFilters.treeDrop}" >
      <rich:treeNodesAdaptor id="TheDateGroup" var="dg" nodes="#{ui$query$newQuery.qryStatement.whereClause.dateGroup}" >
      <rich:treeNode acceptedTypes="wg" reRender="theTree">
      <h:outputText value="#{dg.filterString}" />
      </rich:treeNode>
      <rich:recursiveTreeNodesAdaptor id="whereGroup" roots="#{dg.whereGroups}" var="wg" nodes="#{wg.whereGroups}" >
      <rich:treeNode dragType="wg" acceptedTypes="wf,wg">
      <h:outputText value="#{wg.isAnd}" converter="#{ui$query$setFilters.cvtAndOr}" />
      </rich:treeNode>
      <rich:treeNodesAdaptor id="wf" var="wf" nodes="#{wg.whereFilters}">
      <rich:treeNode dragType="wf" reRender="treePanel">
      <h:outputText value="#{wf.displayString}"/>
      </rich:treeNode>
      </rich:treeNodesAdaptor>
      </rich:recursiveTreeNodesAdaptor>
      </rich:treeNodesAdaptor>
      </rich:tree>


      Java code for drag and drop:
      public void treeDrop(DropEvent dropEvent) {
      UITree tree = ((UITreeNode) dropEvent.getComponent()).getUITree();

      Object dragValue = dropEvent.getDragValue();
      Object dropValue = dropEvent.getDropValue();

      if (dragValue != dropValue) {

      //Drop group will always be a group
      Group dropGroup = (Group) tree.getRowData(dropValue);

      //Drag Item could be a WhereGroup or a WhereFilter
      Object item = tree.getRowData(dragValue);

      if (item instanceof WhereGroup) {
      WhereGroup dragGroup = (WhereGroup) item;
      dragGroup.getParent().removeWhereGroup(dragGroup);
      dropGroup.addWhereGroup(dragGroup);
      } else if (item instanceof WhereFilter && dropGroup instanceof WhereGroup) {
      WhereFilter dragFilter = (WhereFilter) tree.getRowData(dragValue);
      dragFilter.getParent().removeWhereFilter(dragFilter);
      ((WhereGroup) dropGroup).addWhereFilter(dragFilter);
      }

      tree.addRequestKey(tree.getParentRowKey(dragValue));
      }

      }

        • 1. Re: Tree Drag and Drop Problem with recursiveNodesAdapter
          nbelaevski

          Hello,

          I guess the problem is caused by the fact that newly added node is not present in a set of nodes for treeAdaptor, e.g. it is added to some other collection where there is nodes expression evaluating to these items.

          • 2. Re: Tree Drag and Drop Problem with recursiveNodesAdapter
            skarvenz

            The nodes do get added to the correct collection and are in the newly dropped place when the tree is reRendered. I added a "refresh" ajax button that reRenders the tree. After dragging and dropping the nodes, the nodes is always removed from its origional place and is only sometimes shown in its new place. After I click the refresh button, the node will show up where it was dropped.

            After much more testing on this, it seems that the dragging and dropping works when I move a node futher down in the tree. If I try to move a node more towards the top of the tree, it will remove the node but not show it in its new place after the reRender. Once it is reRendered a second time the node will show in its new place. In the example tree I have below, Nodes E, F and Group B all belong to group A. If I move Node E from Group A to Group B the tree will rerender correctly with Node E not showing in Group A and showing in Group B. However, if I move Node C from Group B to Group A, Node C will not show in Group B, but will not show up in Group A until I reRender the tree a second time.

            |--- Group A

            -- Node E
            -- Node F
            |--- Group B
            -- Node C
            -- Node D




            • 3. Re: Tree Drag and Drop Problem with recursiveNodesAdapter
              omidbiz

              Hi,

               

              I have the same issue do you figure it out how to solve it ?

              I've implemented this feature exactly the same as photoalbum and yet it doesn't work please let me know if someone find a solution ?