1 Reply Latest reply on Aug 13, 2009 11:16 AM by John Gilbert

    DropListener Not Invoked

    John Gilbert Apprentice

      For some reason my drop listener is not getting called. It did start working very briefly for no apparent reason, but then stopped again.

      I have included the code. Can anyone see any reason for this not to work?

      I am using 3.3.1.GA and phaseTracker shows that all the phases are executed...

       <rich:dragIndicator id="indicator" />
      
       <h:form id="planningForm">
      
       <h:panelGrid columns="2" width="100%"
       columnClasses="planning-column,planning-column">
      
       <h:panelGrid columns="1" width="100%">
       <c:forEach items="#{milestonePlanner.milestones}" var="mile">
      
       <tt:toggle-panel switchType="client"
       id="m#{mile.milestone.id}TP" opened="true" rendered="true"
       label="#{mile.milestone.name} (#{mile.milestone.date})">
      
       <rich:dropSupport id="m#{mile.milestone.id}Drop" acceptedTypes="Ticket"
       dropValue="#{mile.milestone}"
       dropListener="#{milestonePlannerDropListener.processDrop}"
       eventsQueue="viewQ"
       reRender="planningForm">
       </rich:dropSupport>
      
       <h:dataTable value="#{mile.tickets}" var="tic">
       <h:column>
       <a4j:outputPanel layout="block">
       <rich:dragSupport dragIndicator=":indicator"
       dragType="Ticket" dragValue="#{tic}">
       <rich:dndParam name="label" value="#{tic.title}" />
       </rich:dragSupport>
       <h:outputText value="#{tic.title}"></h:outputText>
       </a4j:outputPanel>
       </h:column>
       </h:dataTable>
       </tt:toggle-panel>
      
       </c:forEach>
       </h:panelGrid>
      
       <tt:toggle-panel switchType="client" id="unscheduledTP"
       opened="true" rendered="true" label="#{messages['Unscheduled']}">
      
       <rich:dropSupport id="unscheduledDrop" acceptedTypes="Ticket"
       dropValue="unscheduled"
       dropListener="#{milestonePlannerDropListener.processDrop}"
       eventsQueue="viewQ"
       reRender="planningForm">
       </rich:dropSupport>
      
       <h:dataTable value="#{milestonePlanner.unscheduled}" var="tic">
      
       <h:column>
       <a4j:outputPanel layout="block">
       <rich:dragSupport dragIndicator=":indicator"
       dragType="Ticket" dragValue="#{tic}">
       <rich:dndParam name="label" value="#{tic.title}" />
       </rich:dragSupport>
       <h:outputText value="#{tic.title}"></h:outputText>
       </a4j:outputPanel>
       </h:column>
      
      
       </h:dataTable>
       </tt:toggle-panel>
      
       </h:panelGrid>
       </h:form>
      
      


      @Name("milestonePlanner")
      @Scope(ScopeType.SESSION)
      @AutoCreate
      public class MilestonePlanner {
      
       ...
      
       @Name("milestonePlannerDropListener")
       @Scope(ScopeType.EVENT)
       @AutoCreate
       @Transactional
       public static class MilestonePlannerDropListener implements DropListener {
      
       public void processDrop(DropEvent dropEvent) {
       Dropzone dropzone = (Dropzone) dropEvent.getComponent();
       System.out.println("SRC: " + dropEvent.getSource());
       scheduleTicket(dropEvent.getDragValue(), dropzone.getDropValue());
       }
      
       public void scheduleTicket(Object drapTicket, Object dropValue) {
       System.out.println("DRAG: " + drapTicket + ", DROP: " + dropValue);
       }
       }
      }
      


        • 1. Re: DropListener Not Invoked
          John Gilbert Apprentice

          The problem appears to have been due to the fact that I was not caching my data objects between requests.

          For example:

          public List<Ticket> getUnscheduled() {
           Query qry = entityManager.createQuery("from Ticket");
           return qry.getResultList();
          }
          


          instead of

          public List<Ticket> getUnscheduled() {
           if (unscheduled == null) {
           Query qry = entityManager.createQuery("from Ticket");
           unscheduled = qry.getResultList();
           }
           return unscheduled;
          }