droplistener not called
webera Oct 20, 2009 1:13 PMHi,
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" %>
<html>
<head>
<title>DnD Test</title>
</head>
<body>
<f:view>
<rich:dragIndicator id="indicator" />
<rich:scrollableDataTable value="#{cars.allCars}" var="car" id="cartable"
frozenColCount="1"
first="0"
rows="5"
width="300px"
height="396px">
<rich:column width="150px">
<f:facet name="header" >
<h:outputText value="Name"/>
</f:facet>
<a4j:outputPanel>
<!-- Drag support for car.name -->
<rich:dragSupport dragIndicator=":indicator" id="carDrag" dragType="carname" dragValue="#{car}">
<rich:dndParam name="label" value="#{car.name}"/>
</rich:dragSupport>
<h:outputText id="cn" value="#{car.name}"/>
</a4j:outputPanel>
<f:facet name="footer">
<h:outputText value="Name"/>
</f:facet>
</rich:column>
<rich:column width="150px">
<f:facet name="header">
<h:outputText value="Price"/>
</f:facet>
<h:outputText value="#{car.price}"/>
<f:facet name="footer" >
<h:outputText value="Price"/>
</f:facet>
</rich:column>
</rich:scrollableDataTable>
<rich:panel id="dropPanel" style="width:100px;height:100px;">
<f:facet name="header">
<h:outputText value="Drop box" />
</f:facet>
<!-- Drop support for car.name -->
<rich:dropSupport acceptedTypes="carname" dropValue="carname" reRender="cartable" dropListener="#{cars.processDrop}">
</rich:dropSupport>
</rich:panel>
<rich:panel id="noDropPanel" style="width:100px;height:100px;">
<f:facet name="header">
<h:outputText value="No Drop box" />
</f:facet>
<!-- Drop support for car.name -->
<rich:dropSupport acceptedTypes="noname"></rich:dropSupport>
</rich:panel>
</f:view>
</body>
</html>
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