3 Replies Latest reply on Apr 22, 2011 5:54 AM by mausbull

    Problem with dropTarget inside a4j:repeat/dataTable

    mausbull

      Hi,

       

      I have the following page setup:

       

      1 - ExtendedDataTable with a selectionListener -> this renders according to the selection an

      2 - a4j:repeat with dropTargets (also tried to put them in a rich:dataTable instead of a a4j:repeat)

      3 - a a4j:repeat with dragSource

       

      When I now load the page, select a row in the ExtendedDataTable (which now renders the dropTargets), and then drag something from the dragSource it is

      - NOT recognized by the dropTarget

      - ALL subsequent selections/actions which trigger a render are ignored (e.g.: selecting another row in the ExtendedDataTable).

       

      When I reload the page everything works as expected.

      Moreover, it also works immediately when I put the dropTarget outside of the a4j:repeat.

       

      Does anybody know a solution for this problem?

       

      Thanks Stephan

        • 1. Problem with dropTarget inside a4j:repeat/dataTable
          ilya_shaikovsky

          please provide sources.

          • 2. Problem with dropTarget inside a4j:repeat/dataTable
            mausbull

            Hi Ilya,

             

            I'll try to create a testcase for that. Currently, the page + beans are too intertwined.

            • 3. Re: Problem with dropTarget inside a4j:repeat/dataTable
              mausbull

              Hi,

               

              took me a bit to break it down but now I have an example that shows the described behavior:

               

              When I load the page (simple.xhtml) with a fresh session and select the first item in the h:selectOneMenu the two drag and drop lists get rendered as expected but on subsequent selections nothing is rendered anymore (when I change the selection).

              However, when I reload the page everything works as expected and the different lists appear according to the selected item.

              After clearing the session the bug occurs again.

               

              Code:

               

              simple.xhtml

               

              <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
                                    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
              <f:view contentType="text/html"
                      xmlns="http://www.w3.org/1999/xhtml"
                      xmlns:ui="http://java.sun.com/jsf/facelets"
                      xmlns:h="http://java.sun.com/jsf/html"
                      xmlns:f="http://java.sun.com/jsf/core"
                      xmlns:rich="http://richfaces.org/rich"
                      xmlns:a4j="http://richfaces.org/a4j">
              
              <html>
              <h:head>
                  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />     
              </h:head>
              
              <h:body>
              
                  <div id="main" style="padding: 20px;">
              
                          <h:form>
              
                              <a4j:region>
                                  <h:selectOneMenu 
                                      id="runMenu" 
                                      styleClass="alfredComboBoxLarge"
                                      value="#{simple.selection}">
              
                                      <f:selectItems value="#{simple.upperSelection}" var="mySel"
                                          itemLabel="#{mySel}" itemValue="#{mySel}">
                                      </f:selectItems>
              
                                      <a4j:ajax render="dnd" execute="@region" />
              
                                  </h:selectOneMenu>
                              </a4j:region>
              
              
                          </h:form>
                          <rich:panel id="dnd" header="dndTest" >
              
                              <div style="float: left; border: solid; padding: 5px;">
                                  <a4j:repeat value="#{simple.dragList}" var="drag">
                                      <a4j:outputPanel layout="block" styleClass="alfredPrepSampleDrag" >    
                                          #{drag}
                                          <rich:dragSource 
                                                 type="myType"
                                                 dragValue="#{drag}" />
              
              
                                      </a4j:outputPanel>
                                  </a4j:repeat>
                              </div>
              
                              <div style="float: left; border: solid; padding: 5px; margin-left: 10px;">
                                  <a4j:repeat value="#{simple.dropList}" var="drop">
                                      <a4j:outputPanel layout="block" styleClass="alfredPrepSampleDrag" >    
                                          #{drop}
                                          <rich:dropTarget 
                                                      acceptedTypes="@all" 
                                                      dropValue="#{drop}"
                                                      dropListener="#{simpleDropController.processDrop}"
                                                        render="dnd" />
                                      </a4j:outputPanel>
                                  </a4j:repeat>
                              </div>            
              
                          <div style="clear:both" />
                      </rich:panel>
              
                  </div>
              
              </h:body>
              </html>
              </f:view>
              

               

               

              Simple.java

               

              import java.util.ArrayList;
              import java.util.List;
              
              import javax.ejb.Stateful;
              import javax.faces.bean.SessionScoped;
              import javax.inject.Named;
              
              /**
               * Simple bean for testing richfaces dnd
               */
              @Named
              @Stateful
              @SessionScoped
              public class Simple
              {
                private List<String> upperSelection;
              
                private String selection;
              
                private List<String> dragsFirst;
                private List<String> dragsSecond;
              
                private List<String> dropsFirst;
                private List<String> dropsSecond;
              
                public Simple() 
                { 
                  this.upperSelection = new ArrayList<String>();
                  upperSelection.add("first");
                  upperSelection.add("second");
              
                  //First
                  dragsFirst = new ArrayList<String>();
                  dragsFirst.add("drags_first_1");
                  dragsFirst.add("drags_first_2");
                  dragsFirst.add("drags_first_3");
              
                  dropsFirst = new ArrayList<String>();
                  dropsFirst.add("drops_first_1");
                  dropsFirst.add("drops_first_2");
                  dropsFirst.add("drops_first_3");
              
                  //Second    
                  dragsSecond = new ArrayList<String>();
                  dragsSecond.add("drags_second_1");
                  dragsSecond.add("drags_second_2");
                  dragsSecond.add("drags_second_3");
              
                  dropsSecond = new ArrayList<String>();
                  dropsSecond.add("drops_second_1");
                  dropsSecond.add("drops_second_2");
                  dropsSecond.add("drops_second_3");
              
                }
              
              
              
                public List<String> getDragList() {
                  if (selection == null)
                    return null;
              
                  if (selection.equals("first")) {
                    return dragsFirst;
                  } else {
                    return dragsSecond;
                  }      
                }
              
                public List<String> getDropList() {
                  if (selection == null)
                    return null;
              
                  if (selection.equals("second")) {
                    return dropsFirst;
                  } else {
                    return dropsSecond;
                  }      
                }
              
                //GETTER SETTERS (excluded here)
              }
              

               

               

               

              Thanks for your help

              Stephan