cast your model to ListModelList and you have the method. When you don't see the name your renderer isn't applied Try invalidate the combobox
chillworld ( 2014-08-27 11:53:40 +0800 )edit-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi, I have created combobox of MyClass items, each item has attribute "name", which is being displayed in combobox via renderer. My problem is, that I am getting null when I call
combobox.getSelectedItem().getValue();
its null. But when I call
combobox.getSelectedIndex();
i get the proper index of selected item.
This is way, I create combobox:
Combobox combobox = new Combobox();
MyRenderer myRenderer = new MyRenderer();
combobox.setItemRenderer(myRenderer);
combobox.setModel(new ListModelList<MyClass>(myClassList));
MyRenderer class:
public class MyRenderer implements ComboitemRenderer {
public void render(Comboitem item, Object data, int index) throws Exception {
item.setLabel(((MyClass) data).getName());
}
}
Can someone please explain me, where could be possible problem, or how to get selected item from combobox properly?
Thx.
Try this because you have an model behind the combobox.
combobox.getModel().getSelection();
Greetz chill.
cast your model to ListModelList and you have the method. When you don't see the name your renderer isn't applied Try invalidate the combobox
chillworld ( 2014-08-27 11:53:40 +0800 )editAsked: 2014-08-27 07:53:07 +0800
Seen: 69 times
Last updated: Aug 27 '14
adding a menuitem with image on Menubar
can somebody give the use of imagecontent in menuitem ? [closed]
label in org.zkoss.zul.Messagebox must be middle aligned [closed]
Grid with frozen column shows unnecessary scrollbar
Component with independents columns
ZK ComboBox constraint firing on getSelectIndex()
Problems with visible/invisible grids using flex
A container should have a disable attribute.
Video inside: Processing... not translated to set org.zkoss.web.preferred.locale in zk.xml