-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi everyone. I created a simple project. I'm using SimpleListModel to set model for combobox. - zul file:
<?page title="new page title" contentType="text/html;charset=UTF-8"?>
<zk>
<window title="new page title" border="normal"
apply="composer.ComboboxComposer">
<combobox id="combobox" autodrop="true">
<template name="model">
<comboitem label="${each.label}"></comboitem>
</template>
</combobox>
</window>
</zk>
- here is the composer: public class ComboboxComposer extends SelectorComposer<component> { /** * */ private static final long serialVersionUID = -6520517581633968667L; @Wire private Combobox combobox;
@Override
public void doAfterCompose(Component comp) throws Exception {
super.doAfterCompose(comp);
NodeDeptUser ndu1 = new NodeDeptUser("label 1", "desc 1");
NodeDeptUser ndu2 = new NodeDeptUser("label 2", "desc 2");
NodeDeptUser[] array = {ndu1, ndu2};
ListModel model = new SimpleListModel(array);
combobox.setModel(model);
}
}
and this is NodeDeptUser.java:
public class NodeDeptUser {
private String label;
private String description;
public NodeDeptUser(String label, String description) {
this.label = label;
this.description = description;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
}
When I run the project, there is nothing in combobox. What is wrong? I have the same issues with using ListSubModel, but when I use ListModelList, everything is fine.
Hello bkstorm,
Please refer to the following url (Autocomplete by ListSubModel) in order to accomplish your task:
http://books.zkoss.org/wiki/ZKComponentReference/Input/Combobox
Best Regards,
Darksu
I have read it many times. My mistake. I assumed that combobox compares compoitems's label to find matched value. That is wrong. So I implement my comparator then my code works. Thank you very much.
That totally works well in my project too! THX man! Best Regards !
Asked: 2015-03-26 03:25:09 +0800
Seen: 14 times
Last updated: Mar 26 '15