Hi there,
I need help getting ListSelect selected items if the ListSelect is in multiselection mode.
I saw that I can use ListSelect.getProperty().
Due to my poor knowledge in java I don’t know how to get a collection or something I can iterate on.
Thanks in advance to anybody can help me.
Paolo
I think that this is what you are looking for.
for (Iterator i = listSelect.getItemIds().iterator(); i.hasNext();) {
Object iid = (Object) i.next();
if(listSelect.isSelected(iid))
{
System.out.println("Selected");
}
}
Hope it helps,
Marios
The getValue() method of ListSelect in multiselect mode (as well as some other multiselect fields) returns a Set of selected item IDs.
Thanks Marios,
it works; can I Iterate only on the selected items on a ValueChange event? (i.e. without scrolling all items that can be a large number).
Paolo
Thanks Henri,
Well, I don.t know how to cast the Set on the objects of the containerDataSource.
Paolo
I hope it help you:
Set <Item>values=(Set<Item>) listselect.getValue();
for (Object v:values){
System.out.println("This is selected : " + listselect.getitem(v).getItemProperty(the property-).getValue.toString());
}