2 Replies Latest reply on Sep 18, 2007 10:46 AM by Maksim Kaszynski

    null drag value in listener

    ASD ASD Newbie

      Hi, I need some help, i´ve been trying to get what is happening for two day´s but I just can´t. The event.getDragValue() function returns null.

      <f:view>
       <center>
       <rich:dragIndicator id="indicator"></rich:dragIndicator>
       <h:form>
       <h:panelGrid styleClass="generalTable">
       <rich:panel>
       <rich:dataTable id="iItems" value="#{PjCreationDataBean.initItems}" var="item">
       <rich:column>
       <a4j:outputPanel style="border:1px;">
       <rich:dragSupport dragType="item" dragIndicator=":indicator" dragValue="asd">
       <rich:dndParam name="label" value="#{item.item}"/>
       </rich:dragSupport>
       <h:outputText value="#{item.item}"/>
       </a4j:outputPanel>
       </rich:column>
       </rich:dataTable>
       </rich:panel>
       <rich:panel>
       <rich:dropSupport acceptedTypes="item" dropListener="#{WeaponDropEventListener.processDrop}"
       dropValue="#{PjCreationDataBean.selectedItems}">
       </rich:dropSupport>
       <rich:dataTable id="sItems" value="#{PjCreationDataBean.selectedItems}" var="item">
       <rich:column>
       <a4j:outputPanel style="border:1px;">
       <h:outputText value="#{item.item}"/>
       </a4j:outputPanel>
       </rich:column>
       </rich:dataTable>
       </rich:panel>
       </h:panelGrid>
       <center>
       </h:form>
       </f:view>
      


      package request;
      
      import org.ajax4jsf.dnd.event.DropListener;
      import org.ajax4jsf.dnd.event.DropEvent;
      import org.ajax4jsf.dnd.Dropzone;
      import java.util.ArrayList;
      import rolSystem.initConfig.InitItem;
      import java.util.Iterator;
      /**
       *
       * @author Seba
       */
      public class WeaponDropEventListener implements DropListener{
      
       /** Creates a new instance of WeaponDropEventListener */
       public WeaponDropEventListener() {
       }
      
       public void processDrop(DropEvent event) {
       Dropzone dropZone = (Dropzone) event.getComponent();
       ArrayList<InitItem> selected = (ArrayList) dropZone.getDropValue();
       System.err.print(selected.size());
       Object ob = event.getDragValue();
       if(ob == null)
       System.err.print("objeto nulo");
       selected.add((InitItem) event.getDragValue());
      
       }
      }
      


      Thanks

        • 1. Re: null drag value in listener
          haoues klklk Newbie

          Hi,

          Have you resolved your problem ? Because I'm actually in the same crap ;).

          Any reply would be welcome. Thanks.

          • 2. Re: null drag value in listener
            Maksim Kaszynski Apprentice

            chizzzo, I tried the following method instead of yours

            public void processDrop(DropEvent event) {
             Dropzone dropZone = (Dropzone) event.getComponent();
             ArrayList<InitItem> selected = (ArrayList) dropZone.getDropValue();
             System.err.print(selected.size());
             Object ob = event.getDragValue();
             System.out.println("DragValue " + event.getDragValue());
             System.out.println("DropValue " + event.getDropValue());
             if(ob == null)
             System.err.print("objeto nulo");
            
             }
            


            and got
            0DragValue asd
            DropValue []

            in console.

            So, for me it works.
            RichFaces 3.1.1 Snapshot, JSF RI 1.2_04-b16-p02, Tomcat 6.0.

            What is your environment?