1 2 Previous Next 17 Replies Latest reply on Jun 12, 2013 1:45 PM by bleathem Go to original post
      • 15. Re: Problem with picklist (prefill & select)
        bleathem

        Well, this is odd.  Can you provide some *simple* sample code demonstrating this?  By simple, I mean where all non-relavant code has been removed.

        • 16. Re: Problem with picklist (prefill & select)
          jn.colin

          Hi Brian

          I made a simple app:

          • /Items.xhtml is the frontend
          • Item is the element to be displayed in the list
          • ItemBean is the managed bean that builds the available and selected lists
          • ItemConverter is the converter

           

          As you see in ItemBean's constructor, depending on the way I build the selectedList, it gets displayed properly or not

           

          the project is using ivy for dependencies, and is build using ant tasks

          • ant resolve-dependencies
          • ant package

           

          should build the war file in /dist

           

          (I now need to figure out how to attach a file to this message :-)

          • 17. Re: Problem with picklist (prefill & select)
            bleathem

            Thanks Jean-Noel Collin for your persistence with this issue.  I ran your sample, and can confirm the behavior you describe.  The fix is to override hashCode for your Item Object, my IDE generated the following hashCode for me:

             

                @Override
                public int hashCode() {
                    return (int) (id ^ (id >>> 32));
                }
            

             

            This however is less than ideal.  While the HashSet used may lead to an efficient implementation, in practice pickList value collections are small enough that iterating over the elements is sufficient.

             

            Can you file a jira issue requesting that we change our implementation to not require the implementation of the hashCode method in the Data objects?  To implement this, we can simply iterate over the collection, invoking the equals method on the individual objects.  This will make it easier for folks to use the pickList.

             

            Thanks!

            Brian Leathem

            1 2 Previous Next