TwinColSelect and setting values in right column

I’ve read through a couple of posts on the same topic. The problem is always the same: there are no visible values in the right hand column of a
TwinColSelect
although
getValue()
does indeed return a
Set
with some members of the type expected.

In my case the TwinColSelect is bound to a bean which ultimately comes from JPA.
My class is called
UserGroup
and it implements
toString(), equals() and hash()
.

Both the left-hand side and the right-hand side contain an underlying value which in both cases is
Set
, as expected. The left-hand side is able to display visible values just fine, supposedly using the
toString()
method on
UserGroup
.

Couple of questions:

  1. Disregarding the problem with the display of values in the right-hand side why is the left-hand side able to display those exact same object types just fine? (I would expect some symmetry: either none of the sides work or both of them work).
  2. The real question: What am I missing that makes the values in the right-hand side invisible?

Thanks.

Peter

So I found out what the question was and I cannot find this documented anywhere …although there’s some logic to it.

Here’s the correct method of populating a TwinColSelect:


  1. Before
    the beans binding you must set potential values in the left-hand column using one of
    TwinColSelect.addItem…
    methods. You must set
    all
    potential values, disregarding if they are currently a selected value in your bean or not. Yes, the
    full
    list of potential values.
  2. Now do the bean binding, e.g.
    BeanFieldGroup.bindFieldsBuffered(userGroup, this)
    or whatever. This sets the right-hand column. Vaadin will automatically remove those values from the left-hand column that you set in step 1 and which are now in right-hand column.

So left-hand column first, then right-hand column.
If you do not comply with this order of events you’ll get the result that the right-hand column seemingly displays nothing.

Peter