Search code examples
zk

ZK Combobox item lost


I put a item in a ComboBox on the doAfterCompose:

Comboitem item = new Comboitem();
item.setValue(user);
item.setLabel(user.getName);
this.usuario.appendChild(item);
this.usuario.setSelectedIndex(0);
this.usuario.setSelectedItem(item);

This works well and i can see the item charged and selected in the window, but when i execute one action of the window and go inside any controller method's, the Combobox "usuario" exists, but has no SelectedItem and no items:

usuario.getSelectedItem()
     null

 usuario.getItems()
     (org.zkoss.zk.ui.AbstractComponent$Children) []

The Combox is defined in the zul:

<combobox width="245px" id="usuario"
                                buttonVisible="false" autodrop="true" />

Solution

  • I have solved it by myself. I manually add a item to a combo that have a model loade, this cause that the item is lost when a Event is send.