3 Replies Latest reply on Aug 21, 2009 2:32 PM by Nick Belaevski

    Please... Need help on DragnDrop Tree...

    Raoul Batista Newbie

      I have the following code almost the same as the demo website except I hoping to enable drag and drop to any folder and not only the
      top folders (under root):

      <rich:dragIndicator id="indicator1" >
       <f:facet name="single">
       <h:graphicImage styleClass="indicatorPicture" value="/richfaces/jQuery/images/{draggedImage}" />
       <rich:dragIndicator id="indicator2" />
       <h:panelGrid columns="2" width="100%" columnClasses="col1,col2">
       <rich:tree ajaxKeys="#{null}" style="width:300px" nodeSelectListener="#{treeDndBean.processSelection}"
       reRender="#{areaToRerender}" ajaxSubmitSelection="true" switchType="client" dragIndicator="indicator2"
       value="#{treeDndBean.treeNode}" var="item" id="tree" treeNodeVar="treeNode"
       dropListener="#{treeDndBean.dropListener}" nodeFace="#{treeNode.leaf ? 'leaf' : 'node'}">
       <rich:treeNode type="node" acceptedTypes="pic">
       <h:outputText value="#{item}"/>
       <rich:treeNode type="leaf" dragType="pic">
       <rich:dndParam name="label" type="drag">#{item}</rich:dndParam>
       <h:outputText value="#{item}"/>
       <a4j:commandButton value="New folder" action="#{treeDndBean.newFolder}" reRender="tree" />
       <a4j:commandButton value="New leaf" action="#{treeDndBean.newLeaf}" reRender="tree" />

      Everything works fine except that the dropListener is never called eventhough it is allowed to drop (based on the drag indicator). I overwrote the isLeaf method of TreeNode in my implementation and I made sure, leaf is really a leaf (that is, it has no children). If I replace
      nodeFace="#{treeNode.leaf ? 'leaf' : 'node'}"

      nodeFace="#{treeNode.parent == null ? 'node' : 'leaf'}"

      I can drop into top folders (same as the demo).

      Another thing I don't understand is that if I write something like nodeFace="#{treeNode.type == 'leaf' ? 'leaf' : 'node'}" when I select a node I have the following exception: Property 'type' not found on type org.richfaces.model.CacheableTreeNodeImpl
      No idea where does CacheableTreeNodeImpl come from and to be honest it is hard to understand how this works with the available documentation.

      I would really appreciate any help...

      Thanks in advance!