TwinColSelect setValue() not working

Hi Guys,

I’m having an issue with a bean backed TwinColSelect.

I am populating my twinColSelect within a FormFactory as such:

TwinColSelect field = new TwinColSelect();
return field;

Then I want to set the selected values for the form. This should happen by form magic, but isn’t.
When I do a: ((TwinColSelect)form.getField(“requiredTrainings”)).setValue(Collections.unmodifiableSet(selectedItems));

This doesn’t update the TwinColSelect - however - do a getValue() after the field has has setValue() called, the new value is returned.

Thoughts? What am I missing here?

Any update to this? I’m having the same issue. I have extended the TwinColSelect to display a list of Authorities, and to select the Authorities that a user already has.

When returning this class as a field from my FormFieldFactory, the left box contains all the Authorities, and the right box is blank. (I’ve ensured the User
return a set of Authorities)

However, when adding this class as a component to a window, it works as expected.

public class AuthoritySelect extends TwinColSelect{

	public AuthoritySelect(User user, IUserService userService){

		BeanItemContainer<Authority> container = 
			new BeanItemContainer<Authority>(Authority.class, userService.getAllAuthorities());

Is there something in the form that resets the value when displayed?

Finally, the TwinColSelect started working when used as a form field.

The issue was that my beans were being loaded by hibernate at 2 different times. So the ‘Authorities’ in the User bean were different instances of the Authorities loaded by the service. When the TwinColSelect compared the values, it showed them as different, therefore, it didn’t select the Users Authorities.

To fix it, I overrode the equals and hashcode methods of Authority. Voila.

Perhaps I missed that somewhere in the documentation.


Hi Jeff,

While I no longer use TwinColSelect in my project, I fixed a lot of these issues by implementing the hashCode() and equals() methods in my model classes. I’m using grails + vaadin and grails didn’t seem to be implementing hashCode in a way that vaadin liked.


Another alternative would be not to use a BeanItemContainer but a BeanContainer, where you can explicitly specify the IDs or e.g. tell it to use a specific property as the ID. If item identifiers have suitable equals() and hashCode(), you do not need to add them to your model classes.

Nice one Henri. I am using a Grails backend, so the classes all have hibernate generated ids. I shall look at adjusting my containers.

Hi everybody,

My name is Abimael. I found I bug when you use Twinselect with BeanContainer.
When you instantiate BeanContainer the IDTYPE,BEANTYPE are differents types and you have following conflitct AbstractSelect function below.
public boolean isSelected(Object itemId) {
if (itemId == null) {
return false;
if (isMultiSelect()) {

return ((Set<?>) getValue()).contains(itemId);

} else {
final Object value = getValue();
return itemId.equals(value == null ? getNullSelectionItemId()
: value);
Alway the return value will be false. This function is used to mark if the value is selected in paintitem function to fill rightcolumn of the component.

The BeanItemContainer works because IDTYPE=BEATYPE like a example

[/size]public class BeanItemContainer extends
AbstractBeanContainer<BEANTYPE, BEANTYPE>

Sorry for my english, I´m brazillian and I ask for help to solve this problem in vaadin 6.7.9.

Based on a quick look, I don’t see what would be the problem in the code.

The value of any AbstractSelect component is the selected item identifier, or in the case of a multiselectable component the set of selected item identifiers.