2 Replies Latest reply on Aug 19, 2013 9:01 AM by yuri_

    Drag-n-drop and rich:tree problem: drop listener is not invoked (RF 4.3.2.Final)

    yuri_

      Hi!

      I have a problem with d-n-d support in rich:tree.

      If the rich:dragSource is nested inside rich:treeNode the drop listener is never called.

      The ajax event is fired and it has javax.faces.partial.event=drop param but the listener method is not invoked.

      Plus, if I place the same dragSource outside the rich:tree it works fine.

      The  snippet is:

       

            <rich:tree id="tree" value="#{organisationalSelectionDialog2.data}" var="item"

                        toggleType="ajax" nodeType="${item.type}" toggleListener="#{organisationalSelectionDialog2.toggleListener}" >

                 <rich:treeNode type="LEAF" id="tree_leaf">

                     <rich:panel id="p1">

                         <h:outputText value="[#{item.typeShortname}] #{item.name}"/>

                     </rich:panel>

                 </rich:treeNode>

                  <rich:treeNode type="NOT-LEAF" id="tree_node" expanded="#{item.expanded}">

                     <rich:panel id="p2">

                        <rich:dragSource type="orgTreeNode" dragValue="123" />

                         <rich:dropTarget id="dt" dropValue="#{item}" acceptedTypes="orgTreeNode" dropListener="#{organisationalSelectionDialog2.dropListener}"

                                          execute="tree" render="tree" />

                          <h:outputText value="[#{item.typeShortname}] #{item.name}" />

                     </rich:panel>

                 </rich:treeNode>

             </rich:tree>

             </rich:panel>

       

             <!-- the same dragSource outside the tree works fine-->

             <rich:panel>

                 <h:outputText value="source" />

                 <rich:dragSource type="orgTreeNode" dragValue="123" />

             </rich:panel>

       

      The listener's signature is: public void dropListener(org.richfaces.event.DropEvent e).

      Environment: WebLogic 12.1.1.0, JSF Mojarra 2.1.14, Richfaces 4.3.2.Final.

        • 1. Re: Drag-n-drop and rich:tree problem: drop listener is not invoked (RF 4.3.2.Final)
          yuri_

          In case someone runs into it there's a quick workaround:

           

                <rich:tree id="tree" value="#{orgDialog.data}" var="item"

                            toggleType="ajax" nodeType="${item.type}" toggleListener="#{orgDialog.toggleListener}" >

                     <rich:treeNode type="LEAF" id="tree_leaf">

                         <rich:panel id="p1">

                             <h:outputText value="[#{item.typeShortname}] #{item.name}"/>

                         </rich:panel>

                     </rich:treeNode>

                      <rich:treeNode type="NOT-LEAF" id="tree_node" expanded="#{item.expanded}">

                         <rich:panel id="p2">

                            <rich:dragSource type="orgTreeNode" dragValue="#{item}" />

                            <rich:dropTarget id="dt" dropValue="#{item}" acceptedTypes="orgTreeNode" />

           

                            <a:ajax event="mousedown" listener="#{orgDialog.mouseDownListener(item.id)}" />

                            <a:ajax event="mouseup" listener="#{orgDialog.mouseUpListener(item.id)}" render="tree" />

           

                            <h:outputText value="[#{item.typeShortname}] #{item.name}" />

                         </rich:panel>

                     </rich:treeNode>

                 </rich:tree>

                 </rich:panel>

           

          class OrgDialog {

              public void mouseDownListener(String id)

              public void mouseUpListener(String id)

              ...}

          Id params to identify the source and target items, dragSource and dropTarget tags are still needed to render the dragging.

          1 of 1 people found this helpful
          • 2. Re: Drag-n-drop and rich:tree problem: drop listener is not invoked (RF 4.3.2.Final)
            yuri_

            Finally found the problem: my tree node impl was like this

             

            public class OrgTreeNode extends org.richfaces.model.TreeNodeImpl { ... }

             

            changed it to

             

            public class OrgTreeNode implements javax.swing.tree.TreeNode.TreeNode {

                //implement methods

            }

             

            after that d-n-d events and ajax-type selection work ok.