0

creating Combobox in java

asked 2010-06-21 14:42:29 +0800

adamzk gravatar image adamzk
207 1

Hello

In my java code I've got some code:
Combobox combo = new Combobox();

List dict = dao.getAll();
combo.setModel(new ListModelList(dict));

combo.setReadonly(true);
cell.appendChild(combo);

Cell is where I want to put my combo. In the model are 2 objects, but when I run application there are no items in the list. What am I doing wrong?

Regards

delete flag offensive retag edit

7 Replies

Sort by ยป oldest newest

answered 2010-06-21 15:13:37 +0800

vinhvo gravatar image vinhvo
369 3

did dao.getAll(); return something ?

link publish delete flag offensive edit

answered 2010-06-22 01:08:07 +0800

jaikarthik gravatar image jaikarthik
69

u havent specified renderar in ur code.
If u r building combobox from java then renderar ia needed.

public class ComboitemRenderer implements ComboitemRenderer{
public void render(Comboitem comboitem, Object data) throws Exception {
dataistance= (cast to appropriate class) data;
comboitem.setLabel(dataistance.getVal1());
comboitem.setValue(dataistance.getVal2());

}

}

in ur code use

ComboitemRenderer renderer = new ComboitemRenderer ();
combo.setItemRenderer(renderer);

Hope it halps

Thanks
Jaikarthik Natarajan

link publish delete flag offensive edit

answered 2010-06-22 02:13:44 +0800

adamzk gravatar image adamzk
207 1

Without renderer is almost OK - the label is not what I want but there is some label, but when I set the renderer on the combo situation goes bad and there is nothing displayed in the combo - but renderer is working - I can see logs from it. Why renderer removes elements from combo?

link publish delete flag offensive edit

answered 2010-06-22 05:18:41 +0800

adamzk gravatar image adamzk
207 1

The label in my object was empty - now after correcting the code is OK.

link publish delete flag offensive edit

answered 2010-06-22 05:32:54 +0800

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

please, share us your correction

link publish delete flag offensive edit

answered 2010-06-22 13:32:18 +0800

adamzk gravatar image adamzk
207 1

The field, which I used as the label, was null - that's the clue.

link publish delete flag offensive edit

answered 2010-06-23 02:03:43 +0800

adamzk gravatar image adamzk
207 1

No I've got another problem - when I set value of the combo only this value is presented in the items list of the combo, how to set its value and the rest of the items together?

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: 2010-06-21 14:42:29 +0800

Seen: 727 times

Last updated: Jun 23 '10

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