5 Replies Latest reply on Feb 29, 2008 7:29 AM by stefan r

    Tree not rerendering on drag and drop

    Danielle Wheeler Newbie

      Recently I've created drag and drop listeners in my backing bean for a tree structure. As I drag and drop tree nodes on the JSP I can see in MyEclipse that the nodes are being added to and removed from the appropriate places. The problem is that the 'reRender' attribute of the tree does not appear to be funtioning. If I create a a4j:commandButton such as the 'Refresh Tree' one below, the tree will reRender when I click it. The tree will also rerender correctly if I manually refresh the page. I'd prefer that the tree rerender as soon as I finish a drop action however. Does anyone know or have any ideas on how to do this?

      Note: My treeNodes have to have dataTables in them so I can display multiple columns per node. I realize this creates another set of nested tables in XHTML but I don't know a way around it.

      Tree Code from JSP:

      <a4j:form>
      
       <rich:tree
       id="tree1"
       nodeFace="#{item.type}"
       showConnectingLines="false"
       style="width:300px;"
       value="#{createTree.tree}"
       var="item"
       dragType="treeNode"
       acceptedTypes="treeNode"
       dragListener="#{createTree.processDrag}"
       dropListener="#{createTree.processDrop}"
       reRender="tree1">
      
       <rich:treeNode
       type="#{item.type}">
      
       <t:dataTable
       var="row"
       value="#{item.rows}">
      
       <t:columns
       var="column"
       value="#{item.columnText}">
      
       <h:outputText value="#{column}"/>
      
       </t:columns>
      
       <t:column>
      
       <a4j:commandLink
       ajaxSingle="true"
       value="View"
       action="#{createTree.commandAction}"
       actionListener="#{createTree.onViewSelect}"/>
      
       </t:column>
      
       </t:dataTable>
      
       </rich:treeNode>
      
       </rich:tree>
      
       <a4j:commandButton
       action="#{createTree.reset}"
       value="Refresh Tree"
       reRender="tree1" />
      
      </a4j:form>
      


      Relevant Code from the Backing Bean:
      public class CreateTree {
      
      ...
      
       private EntityFamilyTree myDropZone;
       private String myDropType;
       public void processDrop(DropEvent dropEvent) {
      
       myDropZone =
       (EntityFamilyTree)((TreeNodeImpl)((HtmlTree)((HtmlTreeNode)dropEvent.getSource())
       .getParent()).getTreeNode()).getData();
      
       myDropType = dropEvent.getDragType();
       }
      
       public String processDrag(DragEvent dragEvent) {
      
       if(myDropType.equals(dragEvent.getAcceptedTypes())) {
      
       EntityFamilyTree draggedNode =
       (EntityFamilyTree)((TreeNodeImpl)((HtmlTree)((HtmlTreeNode)dragEvent.getSource())
       .getParent()).getTreeNode()).getData();
      
       EntityFamilyTree draggedParent = (EntityFamilyTree)draggedNode.getParent();
      
       String[] draggedUuid = dragEvent.getDragValue().toString().split(":");
      
       // Remove dragged node from its previous parent node
       draggedParent.removeChild(draggedUuid[draggedUuid.length-1]);
      
       // Add dragged node to its new parent node
       myDropZone.addChild(draggedUuid[draggedUuid.length-1], draggedNode);
      
       return "success";
       }
       return "failure";
       }
      
       public String reset() {
       return null;
       }
      }
      


      EntityFamilyTree is a simple class that extends TreeNodeImpl and holds extra properties such as a list for the columns. Any help would be greatly appreciated.

      Thank you in advance,
      Danielle Wheeler