0

Combbox list is not being loaded

asked 2011-08-18 11:36:55 +0800

bhushan2169 gravatar image bhushan2169
138

hi,
I have inserted the data in the list and then added it into the combobox but somehow the combobox is not showing anything please help mi....
my code is as follows

<zscript>
public void loadContacts()
{
dbc.getAllContacts(contacts);
ListModel contactsModel= to.getModel();
System.out.println(contacts.isEmpty());
to.setModel(contactsModel);
}
</zscript>


<combobox id="to" width="400px" buttonVisible="false" autodrop="true">
<comboitem each="@{contacts.com_receivers}">
</comboitem>
</combobox>

whats wrtong with this code>????

delete flag offensive retag edit

11 Replies

Sort by ยป oldest newest

answered 2011-08-18 12:55:47 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

updated 2011-08-18 12:56:58 +0800

not tested:

<zscript>
  public void loadContacts() {
      ListModelList contactsModel= new ListModelList( dbc.getAllContacts(contacts) );
      System.out.println(contacts.isEmpty());
      to.setModel(contactsModel);
     }
</zscript>

best
Stephan

link publish delete flag offensive edit

answered 2011-08-19 00:25:15 +0800

bhushan2169 gravatar image bhushan2169
138

hi thanks for reply..
i executed your code...but it is appending garbage....how to add specific fields of 'contacts list' in combobox???

link publish delete flag offensive edit

answered 2011-08-19 00:42:27 +0800

bhushan2169 gravatar image bhushan2169
138

IT is appending the objects as its...i want to access the lists field..please help me

link publish delete flag offensive edit

answered 2011-08-19 01:32:55 +0800

bhushan2169 gravatar image bhushan2169
138

p.s.
contacts is an Arraylist
getAllContacts returns the arraylist

link publish delete flag offensive edit

answered 2011-08-19 10:40:57 +0800

bhushan2169 gravatar image bhushan2169
138

please help mew I am stuck badly

link publish delete flag offensive edit

answered 2011-08-21 20:45:25 +0800

matthewgo gravatar image matthewgo
375

Please refrer to databinding
And seems there is no such each attribute

each="@{contacts.com_receivers}">

link publish delete flag offensive edit

answered 2011-08-23 01:05:56 +0800

bhushan2169 gravatar image bhushan2169
138

hi matthewgo,
I refered the documentation...and tried using label, value properties...but it still is not working.....could u post a simple example how to can I bind the data...using List....contacts is my list....and com_receivers is beans proerty but somehow it is not working please help me!!!

link publish delete flag offensive edit

answered 2011-08-24 01:50:05 +0800

matthewgo gravatar image matthewgo
375

updated 2011-08-24 01:56:15 +0800

Hi
This is a simple sample:

<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" ?>

<zk><zscript>
	public class Person {
		private String firstName;
		private String lastName;

		public Person(String a, String b) {
			this.firstName = a;
			this.lastName = b;
		}
		public void setFirstName(String firstname) {
			this.firstName = firstname;
		}
		public void setLastName(String lastname) {
			this.lastName = lastname;
		}
		public String getLastName() {
			return this.lastName;
		}
		public String getFirstName() {
			return this.firstName;
		}
	}
	
	public class Test{
		List list;
	
		public Test(){
		list = new ArrayList();
		list.add(new Person("yy", "xx"));
		list.add(new Person("yy", "xx"));
		list.add(new Person("yy", "xx"));
		list.add(new Person("yy", "xx"));
		}
		
		public List getPersons(){
			return list;
		}
	}
	
	
	Test test = new Test();
</zscript>
	<listbox id="lb" model="@{test.persons}">
		<listhead>
			<listheader>A</listheader>
			<listheader>B</listheader>
		</listhead>
			<listitem self="@{each='person'}" value="@{person}">
				<listcell label="@{person.firstName}" />
				<listcell label="@{person.lastName}" />
			</listitem>
	</listbox>
</zk>


is it what you're looking for?

link publish delete flag offensive edit

answered 2011-08-24 05:02:57 +0800

bhushan2169 gravatar image bhushan2169
138

hi matthewgo,
thanks for your reply
Actually i have already implemented it with the listbox successfully....
Now I want to implement it with the ''combobox''.
I want to insert all the contacts in the combobox so that I can search them.

link publish delete flag offensive edit

answered 2011-08-24 05:06:42 +0800

bhushan2169 gravatar image bhushan2169
138

I want same approach as u posted the exmaple but for the combobox

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: 2011-08-18 11:36:55 +0800

Seen: 872 times

Last updated: Aug 26 '11

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