I have this code in ZK:
<zk xmlns="http://www.zkoss.org/2005/zul">
<window id="CreateList" border="normal" mode="modal" width="320px"
apply="org.zkoss.bind.BindComposer"
viewModel="@id('vm') @init('UserMno')">
<label value="First Name"></label>
<listbox model="@bind(vm.allMno)" checkmark="true" multiple="true" selectedItem="@bind(vm.mnoList)"/>
<button id="closeBtn" hflex="1" label="close" onClick="CreateList.detach()" />
</window>
</zk>
And the idea is i have a list with users and if a click in a user, it have a collection of Mno, and when i open a new page all my Mno must to be load in a listbox, but the mno of the User must to be checked
And i have in Java a class with my viewModel, and is:
public class UserMno {
Collection<String> mnoList;
Collection<String> allMno = MnoDAO.getAllMnosByName();
public Collection<String> getMnoList() {
return mnoList;
}
public void setMnoList(Collection<String> mnoList) {
this.mnoList = mnoList;
}
public Collection<String> getAllMno() {
return allMno;
}
public void setAllMno(Collection<String> allMno) {
this.allMno = allMno;
}
@AfterCompose
public void initSetup(@ExecutionArgParam("mnoList") Collection<String> mnoList) {
this.mnoList=mnoList;
}
}
And the java where i pass the user is:
@Command
public void showModal(@BindingParam("languageContributionStatus") UserStatus mnoList) {
//create a window programmatically and use it as a modal dialog.
final HashMap<String, Object> map = new HashMap<String, Object>();
setPickedItemSet(mnoList.getMnoList());
map.put("mnoList", mnoList.getMnoList());
win = (Window) Executions.createComponents("/com.users/CreateMnosUser.zul", null, map);
win.doModal();
}
UserStatus is a class with a collection of Mno, and when i select a user, my user is: mnoList.
Then The idea is:
I have a list of users in a page, and i need load a page, and in that page, i need load a list that the user mno that the user has associated.
But my listbox never load my collection with my selected item. And i do not know, what happen =(.
Can somebody help me?
As you have set multiple="true"
you need to use selectedItems
(with an s) not selectedItem
.
Also I believe you need to init your mnoList Collection:
Collection<String> mnoList = new HashSet<String>();