How to get the selected Items in TwinCol Select?

Hi,

It’s the second thread I make so I’m really new with vaadin.

My problem is that I don’t know how can I get the selected Items at the right column of TwinCol Select to work with,

I have two TwinCol Select Components in my application, with diferent values.
I want the user to select several elements in both Twin Col Select and then, when the user clicks on a button, I want to show them in a new Window (like a list of all the elements selected before in TwinCol Select components).

I don’t know how to get the items selected. I have been looking in the Forum but I don’t find the way to do it.

Anything will be very helpful.

Thank you all in advance

As with any selection component, the getValue() returns a collection of the selected items. Well, their item IDs.

And most TwinColSelects are multiselect, so you will set/get with a java.util.Set param.

Yes, but… maybe the original author (and for sure me) was meaning how to get the currently selected items: that is, the labels where the user clicked on (to get multiple selection, the user has to click holding the CTRL button down).

I digged into the source code of TwinColSelect and I cannot see anything that can do that. As stated above, one can get the whole content of the right column with getValue(), but that’s all.

Am I right?

What “selected values” means for a TwinColSelect is the set of items in the right-hand column, and “highlighted” items are only used to transfer more than one element at a time between the selected and non-selected items. This differs from a ListSelect, where the selection is the set of “highlighted” items.

The two are simply different ways to select multiple items. TwinColSelect does not understand a concept of “selection within the selection”, which what you are referring to would amount to - for TwinColSelect, that would simply be internal state information.

You could of course construct your own equivalent of TwinColSelect (no need for custom client-side components for this, just server side composition of ListSelects and Buttons), which gives you access to such internal state.

Indeed I did just this.

Your explanation of the difference between the ListSelects selection and the TwinColSelect’s selection is clear (thank you). In my personal experience and opinion, it was not so clear and intuitive from all the documentation. I had to find it by myselft, with trial and error and digging into the source code. That was a bit of pain and time wasted (but the code was very clean to read and undestand, to be honest).

In general, I find that Vaadin hides very well several implementation details, offering a robust server-side object model… but sometimes it hides too much. In the web 2.0 era, the programmer needs quite often to know the “internal state” of UI components: the one discussed in this thread is only one example.

I wonder if there is some way to access such internal state, maybe via the underlying GWT implementation/component?

Please Can You share a example code for using SET for getting multi sellected values from right column.

Thanks.