Please... Need help on DragnDrop Tree...
alclientview Aug 21, 2009 5:42 AMI 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}" /> </f:facet> </rich:dragIndicator> <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> <rich:treeNode type="leaf" dragType="pic"> <rich:dndParam name="label" type="drag">#{item}</rich:dndParam> <h:outputText value="#{item}"/> </rich:treeNode> </rich:tree> <a4j:commandButton value="New folder" action="#{treeDndBean.newFolder}" reRender="tree" /> <a4j:commandButton value="New leaf" action="#{treeDndBean.newLeaf}" reRender="tree" /> </h:panelGrid>
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'}"
with
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!
Arnaud.