-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi,
I'm using Borderlayout with North (filter textbox) and Center (listbox).
I use Zk 6.0 databind to fill listbox.
When i open zul on the first time North appear OK.
When i refresh databind North disappear.
Please help.
Thanks in advance,
Miguel Goncalves
Pleae show us the codes. Does your north component have a fixed heigth ?
best
Stephan
Hi Stephan,
I created a sample code to show bug.
Please select Show Items. On the first time North shows correct. Second time North hides.
package j1ekeig4$v2;public class Item {
private Integer id;
private String descricao;public Item(Integer id, String descricao) {
super();
this.id = id;
this.descricao = descricao;
}public Item() {
}public Integer getId() {
return id;
}public void setId(Integer id) {
this.id = id;
}public String getDescricao() {
return descricao;
}public void setDescricao(String descricao) {
this.descricao = descricao;
}}
package j1ekeig4$v2;import java.util.ArrayList;
import java.util.List;
import java.util.UUID;import org.zkoss.bind.AnnotateBinder;
import org.zkoss.bind.annotation.Command;
import org.zkoss.bind.annotation.NotifyChange;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.util.GenericForwardComposer;
import org.zkoss.zul.Tab;public class TestComposer extends GenericForwardComposer<Component> {
/**
*
*/
private static final long serialVersionUID = 7548168648624725680L;private List<Item> items=new ArrayList<Item>();
private Item selectedItem;private Tab tabItems;
public void doAfterCompose(Component comp) throws Exception {
super.doAfterCompose(comp);
AnnotateBinder binder=new AnnotateBinder();
getItems().add(new Item(1, "Miguel"));
getItems().add(new Item(2, "Nelson"));
comp.setAttribute("vm", this);
binder.init(comp, this);
binder.loadComponent(comp, true);
}
@NotifyChange("items")
@Command
public void showItems() {
tabItems.setSelected(true);
getItems().add(new Item(getItems().size()+1, UUID.randomUUID().toString()));
}public List<Item> getItems() {
return items;
}public void setItems(List<Item> items) {
this.items = items;
}public Item getSelectedItem() {
return selectedItem;
}public void setSelectedItem(Item selectedItem) {
this.selectedItem = selectedItem;
}
}
<zk>
<window title="Hello World!!" border="normal" width="800px"
height="500px" apply="j1ekeig4$v2.TestComposer">
<tabbox hflex="1" vflex="1">
<tabs>
<tab label="tab 1" />
<tab label="Items" id="tabItems" />
</tabs>
<tabpanels>
<tabpanel>
<button label="Show Items"
onClick="@command('showItems')" />
</tabpanel>
<tabpanel>
<borderlayout width="100%" height="100%">
<north size="30px" flex="true" splittable="true" minsize="30" maxsize="30" >
<combobox />
</north>
<center autoscroll="true">
<listbox model="@load(vm.items)">
<listhead>
<listheader label="id" />
<listheader label="descricao" />
</listhead>
<template name="model" var="item">
<listitem value="@load(item)">
<listcell
label="@load(item.id)" />
<listcell
label="@load(item.descricao)" />
</listitem>
</template>
</listbox>
</center>
</borderlayout>
</tabpanel>
</tabpanels>
</tabbox>
</window>
</zk>
Thanks,
Miguel Goncalves
Hmmm, i think it's a bug in the timing of the rendering. Please write a bug report.
As a workaround you can call invalidate() on the borderlayout after you have declare the id for it in the zul.
@NotifyChange("items") @Command public void showItems() { tabItems.setSelected(true); borderlayout.invalidate(); getItems().add(new Item(getItems().size()+1, UUID.randomUUID().toString())); }
best
Stephan
Asked: 2012-04-16 13:35:41 +0800
Seen: 259 times
Last updated: Apr 20 '12