3 Replies Latest reply on Apr 13, 2007 1:21 AM by Bram Biesbrouck

    <rich:tree> and Drag and Drop

    Bram Biesbrouck Newbie

      Hello,

      (first of all, the initial pad on the back for such a great work you're doing here, I'm using RichFaces in heavy production and it's great, thanks.)

      I'm trying to get rich:tree DnD to work.
      All is fine, except, it's impossible to drag a tree-node to another (container) tree node (in the same tree). This is a very common action, so it'd be great to get it to work.

      When I drag a tree node to some other <rich:dropSupport> area, it works like a charm, but when I drop it on a treeNode in the same tree, it doesn't fire the backing bean method at all (and doesn't even give me an error it the backing-bean method doesn't exist)

      This is my view-tier code (jsf, a4j, richFaces)

      <h:form>
      
      <rich:dragIndicator id="spaceMemberDndIndicator" />
      
      <a4j:outputPanel layout="block"
      style="margin-right: 5px; float: left;" title="#{messages['dropMembersToAddPublic']}">
      
       <rich:tree value="#{spaceManager.spaceTreeModel.activeNode}"
       var="spaceMemberInstance"
       nodeFace="#{spaceMemberInstance.isContainer}"
       switchType="ajax"
       style="margin-top: 10px; width: 0px; display: block;"
       dragIndicator="spaceMemberDndIndicator"
       dragType="spaceMemberInstance">
      
       <rich:treeNode type="true"
       dropListener="#{spaceManager.dndAddToContainerMember}"
       acceptedTypes="spaceMemberInstance">
       <h:outputText value="#{spaceMemberInstance.entityData.value}" />
       </rich:treeNode>
      
       <rich:treeNode type="false">
       <h:outputText value="#{spaceMemberInstance.entityData.value}" />
       </rich:treeNode>
      
      </rich:tree>
      </a4j:outputPanel>
      </h:form>
      


      The action method is simple:
      public void dndAddToContainerMember(DropEvent event)
      {
       System.out.println("This doesn't print :-(");
      }
      


      My general feeling is like the client doesn't even try to contact the action-backing-bean at all (since it works with 'external' drop-regions), it just returns without any notice or error.

      Btw, #{spaceManager.spaceTreeModel.activeNode} returns a standard TreeNode implementation with a custom bean as data member. If someone thinks this can be the root of error, I'll be happy to post the whole thing here.

      I'm using Seam 1.2.1.GA on JBoss 4.0.5.GA with the latest Ajax4Jsf and RichFaces snapshots.

      Any help is appreciated, since my night is blank, my mind still active and the coffee within reach.

      b.

        • 1. Re: <rich:tree> and Drag and Drop
          Nick Belaevski Master

          Hello!

          We've had some claims that some event handling methods doesn't work with Seam. Can you please try to use nested <rich:dropListener> inside of tree node in order to discover what really causes the problem?

          • 2. Re: <rich:tree> and Drag and Drop
            Bram Biesbrouck Newbie

            Hi,

            Ok, I tried this (rest is same as below)

            <rich:treeNode type="true">
             <h:outputText value="#{spaceMemberInstance.entityData.value}" />
             <rich:dropSupport
             acceptedTypes="[spaceForeignEntity, spaceMemberInstance]"
             dropListener="#{spaceManager.dndAddToContainerMember}">
             <a4j:actionparam name="dndContainerInstanceId"
             value="#{spaceMemberInstance.id}"/>
             </rich:dropSupport>
            </rich:treeNode>
            


            No Luck, doesn't work either.

            When I add a <rich:dropSupport> to the surrounding outputPanel, it works, but I can't find a way to get to know the node that was dropped on. (Seam remoting is my final resort, but I'm afraid of events arriving out of order then...)

            I also tried this concept:

            <a4j:outputPanel>
             <rich:dropSupport />
            
             <rich:tree>
             <rich:treeNode>
             <a4j:actionparam />
             </rich:treeNode>
             </<rich:tree>
            </<a4j:outputPanel>
            


            to no avail... The param isn't picked up by the called backing-bean method.

            Any other ideas/workarounds?

            b.

            • 3. Re: <rich:tree> and Drag and Drop
              Bram Biesbrouck Newbie

              Very little improvement, especially from my point of view (fast, quick and dirty hack or workaround).

              This does what I need it to do (but it's ugly):

              <script>
               dndPreparedContainerId = -1;
              
               function getDndContainerInstanceId()
               {
               return dndPreparedContainerId;
               }
              </script>
              
              <a4j:outputPanel>
               <rich:dropSupport>
               <a4j:actionparam name="dndContainerInstanceId" value="getDndContainerInstanceId()" noEscape="true"/>
               </rich:dropSupport>
              
               <rich:tree>
               <rich:treeNode>
               <rich:dropSupport ondropend="dndPreparedContainerId = #{spaceMemberInstance.id};" />
               </rich:treeNode>
               </<rich:tree>
              </<a4j:outputPanel>
              


              Would be great if RichTree DnD would work natively on Seam, though...

              b.