0

Combobox in databinded listbox seems not to work...

asked 2009-09-17 12:59:38 +0800

christian gravatar image christian
136 2 4

Hi,

i have a databinded listbox. In these listbox i use comboboxes with autocompletion.
The listbox is dynamically generated via databinding.
and these comboboxes don't show their comboitems.

i crated a sample showing my issue:

<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit"?>  
<zk>
	<zscript><![CDATA[
	String[] _dict = { 
		"abacus", "accuracy", "acuity", "adage", "afar", "after", "apple",
		"bible", "bird", "bingle", "blog",
		"cabane", "cape", "cease", "cedar",
		"dacron", "defacto", "definable", "deluxe",
		"each", "eager", "effect", "efficacy",
		"far", "far from",
		"girl", "gigantean", "giant",
		"home", "honest", "huge",
		"information", "inner",
		"jump", "jungle", "jungle fever",
		"kaka", "kale", "kame",
		"lamella", "lane", "lemma",
		"master", "maxima", "music",
		"nerve", "new", "number",
		"omega", "opera",
		"pea", "peace", "peaceful",
		"rock", "RIA",
		"sound", "spread", "student", "super",
		"tea", "teacher",
		"unit", "universe",
		"vector", "victory",
		"wake", "wee", "weak", "web2.0",
		"xeme",
		"yea", "yellow",
		"zebra", "zk",
		
	};
	ListModel dictModel= new SimpleListModel(_dict);

	public class ListPOJO {
		public String name;
		public ListModel dictModel= new SimpleListModel(_dict);
		public ListPOJO(String n) {
			name = n;
		};
	};

	List pojos = new ArrayList();
	for (int i=0; i<1; i++)
		pojos.add(new ListPOJO("row "+i));
	]]>
</zscript>
	<vbox>
		Auto-complete Combobox:
		<combobox id="combo" autodrop="true" model="${dictModel}"/>
	</vbox>
	<label value="${model}"></label>
	<listbox model="@{pojos}" rows="10">
		<listitem self="@{each=item}">
			<listcell label="@{item.name}"/>
			<listcell><combobox autodrop="true" model="${dictModel}" /></listcell>
		</listitem>
	</listbox>
	<combobox id="combo2" autodrop="true" model="${dictModel}"/>
</zk>

If you test the sample: the comboboxes on the top and on the bottom are working properly. But the combobox in the listbox isn't showing any items in it's drop down list.

Any ideas?

Thanks & Bye,
Chris

delete flag offensive retag edit

3 Replies

Sort by ยป oldest newest

answered 2009-09-18 10:42:26 +0800

Arsen gravatar image Arsen
384 5

This should help

<listbox rows="10">
        <listitem forEach="${pojos}" >
            <listcell label="${each.name}"/>
            <listcell>
                <combobox autodrop="true" model="${dictModel}" />
            </listcell>
        </listitem>
    </listbox>

and of course you need getter for field "name" of class ListPOJO

public class ListPOJO {
		public String name;
                public String getName(){
                return name;
                }
		public ListModel dictModel= new SimpleListModel(_dict);
		public ListPOJO(String n) {
			name = n;
		};
	};

link publish delete flag offensive edit

answered 2009-09-18 16:33:15 +0800

christian gravatar image christian
136 2 4

Hi Arsen,

your solution just removes databinding. My list is very dynamic and changing during runtime, so removing databinding is no option. This is just a short sample to demonstrate my issue...

bye,
chris

link publish delete flag offensive edit

answered 2009-10-06 01:23:45 +0800

PeterKuo gravatar image PeterKuo
481 2

Since you set model to listbox,
why not use renderer?

link publish delete flag offensive edit
Your reply
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

RSS

Stats

Asked: 2009-09-17 12:59:38 +0800

Seen: 406 times

Last updated: Oct 06 '09

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