6 Replies Latest reply on Sep 4, 2012 7:51 PM by Brendan Healey

    rich:pickList source populated twice.

    Rui Albuquerque Newbie

      Hi. In my project, my rich:pickList source is being populated twice, resulting in every element being duplicated.  I checked the List that feed the source column and thats not the problem (i created a method that eliminated duplicates and the error still happend...)

       

       

      any Idea on what could be the problem?

      Here's the pickList code:

       

       

        • 1. Re: rich:pickList source populated twice.
          Rui Albuquerque Newbie
           

          <h:form>

          <rich:panel style = "width:580px;float:right;margin-righ:5px">


          <f:facet name = "header"><h:outputText value = "Select Card"/></f:facet>

          <rich:pickList value="#{UpperTrayBean.selectedCards}" sourceCaption="Available Cards" targetCaption="Chosen Cards"

                      listWidth="165px" listHeight="100px" orderable="true" switchByDblClick="true"

                      style="text-align: center; margin-left: 35px"

                      onremoveitems="alert('Are you sure you want to remove this Cards?');"

                      ontargetclick="test(event);" id = "pickList">

                      <f:selectItems value="#{UpperTrayBean.getCards()}" var="cards"  itemLabel="#{cards.getSlot()}" />

                      <f:converter converterId="CardsConverter" />

          </rich:pickList>


          <div>

            <h:form>

          <h:commandButton value="Submit" reRender = "dataTable" style = "width:65px; margin-left:220px"/>

          </h:form>


          </div>           
                    

          </rich:panel>

          </h:form>

          • 2. Re: rich:pickList source populated twice.
            Brendan Healey Master

            Hi, f:selectItems value="#{UpperTrayBean.getCards}" getCards should be a List<Something> with a getter and setter.

            Lose the (). What is not intuitive is that this needs to be a list of both the selected and unselected items. The value

            attribute also needs to point to a List<Something>, and this is of course the selected items. The component will

            work out from the full list and the selected list what is not selected.

             

            If you need to have valueChangeListener style functionality so that a server method executes when items are

            selected or unselected please see my reply in this post:

             

            https://community.jboss.org/message/729682#729682

             

            Regards,

            Brendan.

             


            Freelance Java Enterprise Developer


            JSF Richfaces Ajax Java 6/7 (scjp) EE 6 HTML CSS JavaScript jQuery MySQL JPA Hibernate Eclipselink

            Spring Oracle SQL JPQL Sybase EJB CDI Glassfish Apache JAX-RS Primefaces UNIX Paypal

            • 3. Re: rich:pickList source populated twice.
              Rui Albuquerque Newbie

              Hi. Thanks for answering.

               

              As to your reply: cards and selectedCards are both LinkedLists<Cards>. But i did as you sugested and in the f:selctItems put only "#{UpperTrayBean.cards} When deployed the list in the pickList still had all the components doubled...

               

              The bean is session Scoped, could that be the reason?

              • 4. Re: rich:pickList source populated twice.
                Brendan Healey Master

                Rui, what interface are you declaring the lists as List or LinkedList?

                 

                 

                 

                Regards,

                Brendan.

                 

                 


                Freelance Java Enterprise Developer


                JSF Richfaces Ajax Java 6/7 (scjp) EE 6 HTML CSS JavaScript jQuery MySQL JPA Hibernate Eclipselink

                Spring Oracle SQL JPQL Sybase EJB CDI Glassfish Apache JAX-RS Primefaces UNIX Paypal and more..

                • 5. Re: rich:pickList source populated twice.
                  Rui Albuquerque Newbie

                  I didn't know that could make a difference.. I thought that, given that LinkedLists are Lists, that shouldn't be a problem, right?

                   

                   

                  But yeah, both cards and selectedCards are declared as: List<Cards> name = new LinkedList<Cards>();

                   

                  Could that be the problem?

                  • 6. Re: rich:pickList source populated twice.
                    Brendan Healey Master

                    I've seen people using ArrayList<Something> = new ArrayList<Something>() and having problems (not with pickList

                    but anyway), what you have is fine of course.

                     

                    I think you must be adding data into cards twice, what method is being used to populate the data? Depending on

                    where and how cards is allocated you may need to call .clear(). Also there are situations where constructors,

                    @PostConstruct methods and especially getters and setters are called multiple times for a request.

                     

                     

                     

                    Regards,

                    Brendan.

                     

                     

                     


                    Freelance Java Enterprise Developer


                    JSF Richfaces Ajax Java 6/7 (scjp) EE 6 HTML CSS JavaScript jQuery MySQL JPA Hibernate Eclipselink

                    Spring Oracle SQL JPQL Sybase EJB CDI Glassfish Apache JAX-RS Primefaces UNIX Paypal and more..