TwinColSelect does not take default values or selections

Hi,
I’m having some problems using the TwinColSelect.

My first problem is that the TwinColSelect doesn’t take a set of values I pass in. So for example:


            HashSet<String> strategies=new HashSet<String>();
			strategies.add("1");
			strategies.add("2");
			strategies.add("3");
				
			TwinColSelect twinSelect = new TwinColSelect(TRADE_STRATEGIES,strategies);
			twinSelect.setWidth(350, Sizeable.UNITS_PIXELS);
			twinSelect.setMultiSelect(true);
			twinSelect.setImmediate(true);
			twinSelect.setValue(strategies);
				
			return twinSelect;

This will not render with values 1,2,3 in the right column.

And then the other problem I’m having (which might be related) is that when I select in item in the left column and click to transfer to the right column, the selected value moves over for a split second and then is returned back to the original column.

I have my TwinColSelect being created from FormFieldFactory and put onto a Form.

Suggestions?

Thanks for your help

Hi, am not 100% sure, but your question might be related to
this one
.

Hi Alexander,
Thanks for responding.

I guess my questions are:

  1. Why does setValue(Collection) not work in my code? Am I missing something?
  2. Why is it that when I click to transfer a selected value over, it paints on the right hand side quickly and then reverts back to the original state?

The component looks pretty straightforward, but its not behaving well for me.

So…
1: When i put your code from the first post in the init() method of my app it does show your collection in the right column for me.
2. I would suggest you to setImmidiate to false - cause as I think you have some problems with commiting your form. Btw, I would think that if the first question appears to you only in case of forms - I would check how properly your Item is bound to the form. However, I am not quite sure as my Vaadin experince is not that great).

Hi Alexander,

Thanks for all your input (and sorry for the barrage of dumb questions)

So I kind of fixed the problem where clicking to copy over doesn’t work - I had two versions of the vaadim jar in my path. I removed one and it almost works.

Now when I click to copy over, it works first time. The second time I click to copy over, it resets back the the original state, which is just to all options.

One other thing I noticed is this -
I’m setting the initial set of already selected values as a Property in an Item. The type is of Collection. (the Item is eventually set as the datasource for the Form) However, when I look up the property (i.e. getValue) i’m returned a type String.

Should I be using a different approach when setting the initial collection?

Not sure why your code doesn’t work but
here’s a working example
.

Initializing the select from a HashSet probably has the item order quite strange.

I’ve gone through the samples and they seem straightforward enough.

The big difference between me and the samples is that my TwinColSelect is on a form and is bound to properties.

Does anybody out there have a working example of this?

I’ve attached a modified version of the SimpleAddressBook example.

Basically, I’ve

  1. added a TwinColSelect and initialize it with a set.
  2. the select is added to the form via the FormFieldFactory
  3. added some debugging statements.

You can see that if you transfer once, it works fine. The second attempt to copy from one column to the other will not work. It resets the select to have no values selected.

The other thing you’ll notice is that if you navigate away from the form and back to the form, in the logs, I print out the value of the property that’s currently bound to the form. And yet

  1. Its not selected in the select box.
  2. a get property.getValue returns a string, not a collection, which is what I would expect for a multi-select box.

Thoughts?

Any help would be greatly appreciated.
11527.java (6.08 KB)

OK…
I’ve figured out all my problems.
In the initMainViewData method, I wasn’t setting the class type for the property bound to the select.

Thanks for taking the time to help out,