4 Replies Latest reply on May 2, 2013 8:25 AM by antonio gallo

    dropListener not executed when dragging Node in rich:tree

    hombre2k Newbie



      I plan to migrate my Seam 2.2 application to Seam 3.1 and Richfaces 4. While testing the drag and drop functionality in rich:tree i noticed the following problem:


      I tried to implement the rich:tree example from the Richfaces 4.1 Component Reference Guide in combination with the Drag and Drop example from the Richfaces 4.2.0.CR1 showcase. In addition to the tree i added two rich:panels with Drag and Drop funtionality to check, whether drag and drop works outside of the tree. The DragIndicator works fine and indicates when the dragged element is placed over an appropriate dropTarget. When i drag from one of the panels and drop on the other panel or a treeNode everything works fine. But when i try to drag a treeNode to one of the two panels or another treeNode the dropListener is not executed. The DragIndicator works correct.

      An other problem is, that event.getDragValue() and event.getDropValue() returns null.

      Any suggestions?


      Here is the code:



      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

      <html xmlns="http://www.w3.org/1999/xhtml"











              .panelc { width:25%; }

              .valign { vertical-align:top; }

              .dropTargetPanel { width: 90%; }

              .footerClass {

              text-align: center;

              padding-top: 5px;







              border:1px solid gray;





              background-image: url("#{facesContext.externalContext.requestContextPath}/images/dnd/default.gif");

              background-position: 5px;

              background-repeat: no-repeat;



              background-image: url("#{facesContext.externalContext.requestContextPath}/images/dnd/accept.gif");

              background-position: 5px;

              background-repeat: no-repeat;

              border:2px solid green



              border:2px solid red;

              background-image: url("#{facesContext.externalContext.requestContextPath}/images/dnd/reject.gif");

              background-position: 5px;

              background-repeat: no-repeat;



          <rich:dragIndicator id="ind" acceptClass="accept" rejectClass="reject" draggingClass="default"><h:outputText value="drag me!" /></rich:dragIndicator>


            <a4j:outputPanel ajaxRendered="false" layout="block">

              <rich:tree value="#{treeBean.rootNodes}" var="station" id="tree" toggleType="client" selectionType="ajax">

                <rich:treeNode id="treenode">

                  <a4j:outputPanel id="node">

                    <h:outputText value="#{station.data}" />

                    <rich:dragSource value="#{station.data}" type="dnd" dragIndicator="ind"/>

                    <rich:dropTarget  value="#{station.data}" acceptedTypes="dnd" dropListener="#{treeBean.processDrop}"/>





            <rich:panel id="dndpanel1">

              <rich:dragSource dragIndicator="ind" value="dragPanel1" type="dnd"/>

              <rich:dropTarget value="dropPanel1" acceptedTypes="dnd" dropListener="#{treeBean.processDrop}"/>


            <rich:panel id="dndpanel2">

              <rich:dragSource dragIndicator="ind" value="dragPanel2" type="dnd"/>

              <rich:dropTarget value="dropPanel2" acceptedTypes="dnd" dropListener="#{treeBean.processDrop}"/>











      package tree;

      import org.richfaces.model.TreeNodeImpl;


      public class DataHolderTreeNodeImpl extends TreeNodeImpl {


          private Object data;


          public DataHolderTreeNodeImpl() {




          public DataHolderTreeNodeImpl(boolean leaf, Object data) {


              this.data = data;



          public Object getData() {

              return data;





          public String toString() {

              return super.toString() + " >> " + data;






      package tree;


      import javax.enterprise.context.SessionScoped;

      import javax.inject.Inject;

      import javax.inject.Named;


      import org.jboss.seam.international.status.Messages;

      import org.jboss.solder.logging.Logger;

      import org.richfaces.event.DropEvent;


      import java.io.Serializable;




      public class TreeBean implements Serializable {





          private static final long serialVersionUID = 1L;


          private DataHolderTreeNodeImpl stationRoot;


          private DataHolderTreeNodeImpl rootNodes;



          private Messages messages;



          private Logger log;


          public DataHolderTreeNodeImpl getRootNodes() {

              if (rootNodes == null) {

                  String[] kickRadioFeed = {"Hall & Oates - Kiss On My List",

                          "David Bowie - Let's Dance",

                          "Lyn Collins - Think (About It)",

                          "Kim Carnes - Bette Davis Eyes",

                          "KC & the Sunshine Band - Give It Up"};

                  stationRoot = new DataHolderTreeNodeImpl(false, "KickRadio");

                  for (int i = 0; i<kickRadioFeed.length; i++) {

                      DataHolderTreeNodeImpl child = new DataHolderTreeNodeImpl(true, kickRadioFeed[i]);

                      stationRoot.addChild(i, child);


                  rootNodes = new DataHolderTreeNodeImpl();

                  rootNodes.addChild(0, stationRoot);


              return rootNodes;



          public void processDrop(DropEvent event) {

              String dragValue = (String) event.getDragValue();

              String dropValue = (String) event.getDropValue();

              messages.info("{0} dropped on {1}", dragValue, dropValue);

              log.infof("%s dropped on %s", dragValue, dropValue);