0

Can't using SimpleListModel and ListSubModel with Combobox

asked 2015-03-26 03:25:09 +0800

bkstorm gravatar image bkstorm
38 3

updated 2015-03-26 03:52:06 +0800

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.

delete flag offensive retag edit

3 Answers

Sort by ยป oldest newest most voted
0

answered 2015-03-26 04:38:22 +0800

Darksu gravatar image Darksu
1991 1 4

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

link publish delete flag offensive edit
0

answered 2015-03-26 06:44:41 +0800

bkstorm gravatar image bkstorm
38 3

updated 2015-03-26 06:45:19 +0800

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.

link publish delete flag offensive edit
0

answered 2015-03-26 07:50:25 +0800

cygorolka gravatar image cygorolka
1
http://www.moja-skarbonka...

That totally works well in my project too! THX man! Best Regards !

link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2015-03-26 03:25:09 +0800

Seen: 14 times

Last updated: Mar 26 '15

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More