-
Bug
-
Resolution: Fixed
-
Normal
-
6.5.0
-
Windows
-
None
"selectedItems" in Listbox component is HashSet Type, it should be LinkedHashSet Type. I am facing an issue in the ordering of items given by selectedItems of listbox components. The property "selectedItems" in component listbox given the selected items in HashSet i.e. in random order. But i need it in LinkedHashSet.
Below is my zul file: list.zul
[code]
<window apply="org.zkoss.bind.BindComposer"
viewModel="@id('vm') @init('List1')">
<listbox model="@bind(vm.senderList)" multiple="true"
selectedItems="@save(vm.selectedSenders)" height="300px">
<listhead>
<listheader label="Sender"></listheader>
</listhead>
<template name="model" var="item">
<listitem value="${item }">
<listcell label="@load(item)"></listcell>
</listitem>
</template>
</listbox>
<div style="text-align:right; padding:5px;">
<button mold="trendy" label="Submit"
onClick="@command('submit')" />
</div>
</window>
[/code]
And my Java Code is as:
List1.java
[code]
public class List1 {
private List<String> senderList;
private Set<String> selectedSenders;
public List<String> getSenderList() {
if (senderList == null)
return senderList;
}
public void setSenderList(List<String> senderList)
public Set<String> getSelectedSenders()
{ return selectedSenders; }public void setSelectedSenders(Set<String> selectedSenders)
{ this.selectedSenders = selectedSenders; } @Command
public void submit() {
System.out.println("Printing Selected Senders...");
for (String sender : selectedSenders)
}
}
[/code]
I/p: Select Sender 2,3,4,5 and click on submit
O/p: on console: It prints Sender 5,3,4,2
I want the o/p to be as "Sender 2,3,4,5".
For more references:
http://www.zkoss.org/forum/listComment/21346-Ordering-Issue-in-selectedItems-in-listbox-component