Drag and Drop: processDrop method never called
nepveul Apr 7, 2008 6:12 PMHi!
I'm trying to implement drag and drop. Here is my code:
View:
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:s="http://jboss.com/products/seam/taglib" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:rich="http://richfaces.org/rich" xmlns:ajax="http://richfaces.org/a4j" template="layout/template.xhtml"> <ui:define name="body"> <h:messages globalOnly="true" styleClass="message"/> <ajax:form> <h:panelGrid id="routineMainGrid" styleClass="routineMainGridStyle" columns="2" columnClasses="routineMainGridCol1,routineMainGridCol2" border="0" cellspacing="1"> <rich:panel id="routineEquipmentPanel"> <f:facet name="header">Exercises</f:facet> <rich:dragIndicator id="indicator"/> <!-- rich:datascroller align="left" for="exerciseTable" maxPages="20" /> <rich:spacer height="10" /> <rich:dataTable id="exerciseTable" rows="10" var="exercise" value="#{exerciseQuery.resultList}" rendered="#{not empty exerciseQuery.resultList}"> <h:column> <f:facet name="header">Id</f:facet> <h:outputText value="#{exercise.id}" /> </h:column> <h:column> <f:facet name="header">Description</f:facet> <h:outputText value="#{exercise.description}" /> </h:column> </rich:dataTable--> <rich:dataGrid value="#{exerciseQuery.resultList}" var="exercise" columns="4" elements="12"> <rich:panel> <rich:toolTip followMouse="true" direction="top-right" showDelay="100" > <span style="white-space:nowrap"> <h:outputText value="#{exercise.description}"/> </span> </rich:toolTip> <rich:dragSupport dragIndicator="indicator" dragType="EX" dragValue="#{exercise}"> <rich:dndParam name="label" value="#{exercise.description}"/> </rich:dragSupport> <f:facet name="header"> <h:outputText value="Exercise #{exercise.id}"></h:outputText> </f:facet> <h:graphicImage value="img/exercises/small/#{exercise.image}" style="text-align:center; cursor:pointer"/> </rich:panel> <f:facet name="footer"> <rich:datascroller></rich:datascroller> </f:facet> </rich:dataGrid> <div style="clear:both"/> </rich:panel> <rich:panel id="routineRoutinePanel"> <f:facet name="header"><h:outputText value="#{routineHome.instance.description}"/></f:facet> <ajax:outputPanel layout="none"> <h:panelGrid columns="1"> <ajax:commandButton value="Add Day" action="#{openRoutineManager.addDay}" reRender="routineDayDataGrid"> <f:param name="routineId" value="#{routine.id}" /> </ajax:commandButton> <rich:dataGrid id="routineDayDataGrid" columnClasses="routineDayDataGridCols" value="#{routineHome.instance.days}" var="day" columns="#{routineHome.instance.numDays}" elements="#{routineHome.instance.numDays}" rendered="#{routineHome.instance.numDays > 0}"> <h:panelGrid columns="1"> <rich:panel styleClass="routineDayPanelStyle" bodyClass="test"> <f:facet name="header"> <h:outputText value="#{day.label}"></h:outputText> </f:facet> <h:panelGrid columns="4" styleClass="dayIconsPanelGrid" columnClasses="dayIconsPanelGridCol"> <ajax:commandButton id="delete1" style="border: 0px;" image="img/left.gif"/> <ajax:commandButton id="delete2" style="border: 0px;" image="img/rename.gif"/> <ajax:commandButton id="delete3" style="border: 0px;" image="img/delete.jpg"/> <ajax:commandButton id="delete4" style="border: 0px;" image="img/right.gif"/> </h:panelGrid> <rich:dropSupport id="drop" acceptedTypes="EX" dropValue="#{day}" action="#{openRoutineManager.test}" dropListener="#{openRoutineManager.processDrop}" reRender="routineRoutinePanel"> </rich:dropSupport> <div style="clear:both"/> </rich:panel> </h:panelGrid> </rich:dataGrid> </h:panelGrid> </ajax:outputPanel> <div style="clear:both"/> </rich:panel> </h:panelGrid> <ajax:log popup="false" level="ALL" style="width: 800px; height: 300px;"></ajax:log> </ajax:form> </ui:define> </ui:composition>
Bean:
package com.blisslogik.fbo.beans; import javax.ejb.Remove; import javax.ejb.Stateful; import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; import javax.persistence.PersistenceContextType; import org.jboss.seam.ScopeType; import org.jboss.seam.annotations.Destroy; import org.jboss.seam.annotations.In; import org.jboss.seam.annotations.Logger; import org.jboss.seam.annotations.Name; import org.jboss.seam.annotations.Scope; import org.jboss.seam.log.Log; import org.richfaces.event.DropEvent; import org.richfaces.event.DropListener; import com.blisslogik.fbo.entity.Day; import com.blisslogik.fbo.entity.DayHome; import com.blisslogik.fbo.entity.RoutineHome; @Stateful @Scope(ScopeType.SESSION) @Name("openRoutineManager") public class OpenRoutineManagerBean implements OpenRoutineManager, DropListener { @Logger private Log log; @PersistenceContext(type=PersistenceContextType.EXTENDED) private EntityManager em; @In(create=true) private RoutineHome routineHome; @In(create=true) private DayHome dayHome; @Remove @Destroy public void destroy() {} public void addDay() { log.info("addDay() called."); Day d = dayHome.getInstance(); d.setLabel("New Day"); dayHome.wire(); routineHome.addDay(d); dayHome.persist(); } public void processDrop(DropEvent event) { // TODO Auto-generated method stub log.info("Drop Listener Fired"); } public void test() { // TODO Auto-generated method stub log.info("TESTTEST"); } }
I can drag. When I drop, there is an ajax request being made. But my processDrop method is never called.
Any ideas why?
I was using 3.1.X and upgraded to 3.2 of richfaces, but it still doesn't work.
Thanks!
Laurent