1 Reply Latest reply on Oct 11, 2012 10:58 AM by ealonso04

    rich:picklist bug (right pane doesnt populate as expected) (RF 4.2)

    emmanueldufour

      the picklist only populate the right side selection list if the objects from the right side list are strictly the same as the ones from the left side list,  as a consequence the only way to populate the right list programmatically is to take objects from the left one.

       

      And this is very annoying, if for example left and right list are obtained from JPA from different entitymanagers then the right list wont populate even though the entities have the same ID etc....

      I would have expected the picklist to at least match left and right items correctly if the objects were SelectItems (based on the value) but it doesnt. In all cases the right list populates only if the following condition is met :

       

      MyClass leftObject,rightObject; //same objects from the left and right list

      if ((Object)leftObject).equals((Object)rightObject)){

      //then right object will be displayed in the right side list

      }

       

      My expectation was that

       

      leftObject.equals(rightObject)

       

      where "equals" is the overriden method in "MyClass" and not the "Object" method was good enough, but it is not

        • 1. Re: rich:picklist bug (right pane doesnt populate as expected) (RF 4.2)
          ealonso04

          Hello emmanuel!

           

          You have to override the hascode as well. This is an example of mine:

           

          @Override

              public int hashCode() {

                  return (this.id.hashCode() * this.label.hashCode() * this.value.hashCode());

              }

           

           

              @Override

              public boolean equals(Object obj) {

                  if (this == obj) return true;

                  else if (obj == null || obj.getClass() != this.getClass())

                      return false;

           

           

                  WorkListWrapper wList = (WorkListWrapper) obj;

                  return this.id == wList.getId() && this.label.equals(wList.getLabel()) && this.value.equals(wList.getValue());

              }

           

          My DTO has id, value and label attributes and is working just fine.

           

          Regards!