6 Replies Latest reply on Dec 16, 2010 3:06 PM by winsterjose

    rich:orderinglist doesn't take multi selection

    gunnarstahl

      Hello Community,

      I have some trouble with how the ordering list works. The following is an excerpt of my ordering list:

       

      <rich:orderingList id="AngebotsListe" listWidth="825px"
                                  listHeight="755px" controlsType="button"
                                  value="#{listModelBean.visibleAngebotElements}"
                                  var="angebotsElement" converter="ProspektElementConverter"
                                  selection="#{listModelBean.selectedAngebotElements}">

       

                                    [Multiple column definitions]

       

                               <a4j:support event="ondblclick" ignoreDupResponses="true"
                                      requestDelay="500"
                                      actionListener="#{listControllerBean.editAngebotsPanelRequested}" reRender="pnlEditAngebotsElementContainer"/>
                                  <a4j:support event="onclick" ignoreDupResponses="true"
                                      requestDelay="500" actionListener="#{listControllerBean.takeSelection}"/>

       

      Whenever I click on one row of the list the listModelBean.selectedAngebotElements is updated with the selected row. The listControllerBean.takeSelection is called and executes the following code:

       

      public void takeSelection(ActionEvent event) {
              logger.debug("In takeSelection...");
              logger.debug("Trying to find component with offering elements...");
              UIComponent component = event.getComponent().getParent();
              logger.debug("Found: " + (component == null ? "<null>" : (component.getClass().getName() + " - " + component.getId())));
              if(component != null) {
                  logger.debug("Component that fired the event: " + component.getClass().getSimpleName() + " - " + component.getId());
                  UIOrderingList orderingList = (UIOrderingList)component;
                  Set<AngebotsElementTO> selection = ListModelBean.getInstance().getSelectedAngebotElements();
                  logger.debug("Selection. "+ (selection == null ? "<null>" : selection.size()) + " - Setting selection in listmodelbean");
              }
              logger.debug("Leaving takeSelection");
          }

       

      The log output shows that one row has been selected.

       

      The same happens when I select multiple rows via <ctrl>+click. But instead of providing me with the list of rows that are selected only the last selected row is shown. Currently I have no way of knowing how many rows have been selected. Which annoys me...

       

      How can I find out which rows of the ordering list have been selected?

       

      Yt,

       

      Gunnar

        • 1. Re: rich:orderinglist doesn't take multi selection
          ilya_shaikovsky

          Strange.. the same code works at http://livedemo.exadel.com/richfaces-demo/richfaces/orderingList.jsf using RF 3.3.3 version.

          • 2. Re: rich:orderinglist doesn't take multi selection
            gunnarstahl

            Hello Ilya, would have thought so too. But apparantly not. I guess the magic lies hidden in the "takeSelection" part of the livedemo example. But the source code for the java part of the livedemo example has not been provided.

             

            So the problem remains. I tried it with "immediate=true" on the ordering list, which performs a bit better. It gives me at least tow entries in the selection set, whenever I have selected more then one row. But even when i have selected 5 rows, I get a set with a size of 2. So effectively nothing has changed for me.

             

            Is there anywhere a working example for this ordering list, complete witth source code for the java stuff? I have looked through many sites on the 'net, but haven't found a proper example.

             

            Yt,

             

            Gunnar

            • 3. Re: rich:orderinglist doesn't take multi selection
              gunnarstahl

              Typical case of RTFM... In my desparation I bought the book "practical richfaces" as an ebook. And this states that the objects in the ordering list need to implement the equals() and hashcode() methods. After letting eclipse generate them now everything works like a charm...

               

              So, problem solved.

               

              Yt,

               

              Gunnar

              • 4. Re: rich:orderinglist doesn't take multi selection
                winsterjose

                I am getting the same issue. I tried using a converter with hashcode and equals, it is not working. Later I changed my datatype as String which doesnt need any converter. Even then the same. SelectionList is always getting populated with the previous selection.

                • 5. Re: rich:orderinglist doesn't take multi selection
                  winsterjose

                  <rich:orderingList value="#{myBean.favoriteItems}"

                  selection="#{myBean.selectedFavoriteItems}" var="fav">

                  <rich:column id="favoritescol">

                  <a4j:outputPanel>

                  <h:outputText id="favoriteid" value="#{fav}"/>

                  <a4j:support event="onclick" action="#{myBean.loadFavorite}" reRender="listShuttle"/>    

                  </a4j:outputPanel>

                  </rich:column> 

                  </rich:orderingList>

                   

                  As you can see I was using a4j:support inside an output panel. If you are putting it outside rich:column, selectionlist is correctly populated.

                  • 6. Re: rich:orderinglist doesn't take multi selection
                    winsterjose

                    But I may need your help.

                     

                    a4j:support  reRenders without having a check. Wherever you click on ordering list, whether its button or item or at the border, the reRender will work. Is there any way to control/prevent Rerender with a condition?