Problem with setting values in right column of TwinColSelect

I’m working on Liferay 6.0.6 and Vaadin 6.6.4.
I am trying to set values in right column of the component TwinColSelect.

I have a TwinColSelect containing employees with display property as name.

Relevant code is-

BeanItemContainer employeeContainer = new BeanItemContainer(
Employee.class, employeeList);

TwinColSelect twinColSelect = new TwinColSelect();



I have a ListSelect called “employeeSelect” from which I get collection of employees. I convert this collection to a Set
and use this Set for setting default values in TwinColSelect. If I do a getValue() after the field has setValue() called,
the new value is returned. But this does not update the right column.

Code -

HashSet employeeSet = new HashSet();
Collection employeeCollection = (Collection) employeeSelect.getItemIds();
Iterator iterator = employeeCollection.iterator();
if(employeeCollection != null) {
if(!employeeCollection.isEmpty()) {
while (iterator.hasNext()) {

What could be the possible problem here?

Just a guess, but do the two components use the same instances of Employee? If not, you need to define suitable equals() and hashCode() methods for them.

Alternatively, you could use BeanContainer instead of BeanItemContainer to have control over what is used as the identifiers (some ID property, an ID generator based on the items or explicit IDs).

Thanks a lot. It worked after defining equals, hashcode and toString methods in Employee :smiley: