2 Replies Latest reply on Oct 21, 2009 2:31 PM by Antonio Weber

    droplistener not called

    Antonio Weber Newbie


      I tried to test the drag'n'drop support of rich faces. As far as I can see there is everything like in the examples from the documentation but the dropListener is not called.

      <!doctype html public "-//w3c//dtd html 4.0 transitional//en">
      <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
      <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
      <!-- RichFaces tag library declaration -->
      <%@ taglib uri="http://richfaces.org/a4j" prefix="a4j" %>
      <%@ taglib uri="http://richfaces.org/rich" prefix="rich" %>
       <title>DnD Test</title>
       <rich:dragIndicator id="indicator" />
       <rich:scrollableDataTable value="#{cars.allCars}" var="car" id="cartable"
       <rich:column width="150px">
       <f:facet name="header" >
       <h:outputText value="Name"/>
       <!-- Drag support for car.name -->
       <rich:dragSupport dragIndicator=":indicator" id="carDrag" dragType="carname" dragValue="#{car}">
       <rich:dndParam name="label" value="#{car.name}"/>
       <h:outputText id="cn" value="#{car.name}"/>
       <f:facet name="footer">
       <h:outputText value="Name"/>
       <rich:column width="150px">
       <f:facet name="header">
       <h:outputText value="Price"/>
       <h:outputText value="#{car.price}"/>
       <f:facet name="footer" >
       <h:outputText value="Price"/>
       <rich:panel id="dropPanel" style="width:100px;height:100px;">
       <f:facet name="header">
       <h:outputText value="Drop box" />
       <!-- Drop support for car.name -->
       <rich:dropSupport acceptedTypes="carname" dropValue="carname" reRender="cartable" dropListener="#{cars.processDrop}">
       <rich:panel id="noDropPanel" style="width:100px;height:100px;">
       <f:facet name="header">
       <h:outputText value="No Drop box" />
       <!-- Drop support for car.name -->
       <rich:dropSupport acceptedTypes="noname"></rich:dropSupport>

      The java-code
      package handler;
      import java.util.ArrayList;
      import javax.faces.context.FacesContext;
      import org.richfaces.event.DropEvent;
      import org.richfaces.event.DropListener;
      public class DDTestHandler implements org.richfaces.event.DropListener {
       private ArrayList<Car> cars = null;
       public DDTestHandler() {
       cars = new ArrayList<Car>();
       cars.add(new Car("BMW Z3", 13000.0));
       cars.add(new Car("Audi Q7", 48000.0));
       public ArrayList<Car> getAllCars() {
       return cars;
       public void setAllCars(ArrayList<Car> cars) {}
       public void processDrop(DropEvent event) {
       FacesContext context = FacesContext.getCurrentInstance();
       cars.add(new Car("VW Polo", 8000.0));
       System.out.println("Registered DROP!!");
      package handler;
      public class Car {
       private String name;
       private Double price;
       public void setName(String name) { this.name = name; }
       public String getName() { return name; }
       public void setPrice(Double price) { this.price = price; }
       public Double getPrice() { return price; }
       public Car(String name, Double price) {
       this.name = name;
       this.price = price;

      cars is a DDTestHandler and has application scope