-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I have a listbox in a zul page with a mold="paging"
<window id="browseWin" title="Eventos" width="720px" border="normal" use="com.inabox.taller.controller.EventoListWindow"> <listbox id="lbEvento" multiple="true" rows="10" mold="paging"> <listhead> <listheader label="Evento" /> <listheader label="Prioridad" width="80px"/> <listheader label="Fecha" width="90px"/> </listhead> </listbox> </window>
Then in my java code:
public void onCreate() { Listbox lbEvento = (Listbox) this.getFellow("lbEvento"); EventoDAO dao = new EventoDAO(); List<EventoBean> eventoList = dao.findAll(); lbEvento.getItems().clear(); for (EventoBean eb : eventoList) { Listitem li = new Listitem(); li.setValue(eb); li.appendChild(new Listcell(eb.getNombre())); li.appendChild(new Listcell(String.valueOf(eb.getPrioridad()))); li.appendChild(new Listcell(eb.getFechaInicioAsString())); lbEvento.appendChild(li); li.addEventListener(Events.ON_DOUBLE_CLICK, new EventListener() { public void onEvent(Event event) throws Exception { onEdit(event); } }); } } }
When I add/delete/udate an item i reload the whole listbox with all the data in my table but i go this messagebox
"The paging component cannot be removed manually. It is removed automatically when changing the mold"
I know it could be a better approach use databinding or a model but I just doing an example for my junior programmers..
Any help?
TIA
It looks like a bug in 3.5.1, could you upgrade to 3.5.2?
I upgraded to 3.5.2 and got the same problem...
I can not reduplicate it in 3.5.2 with my sample code,
could you provide simple one that can duplicate the error ?
by the way, make sure you clear the item with 'lbEvento.getItems().clear();' not 'lbEvento.getChildren().clear();'
my example here, works in 3.5.2 , fail in 3.5.1
<window id="browseWin" title="Eventos" width="720px" border="normal"> <button label="click" > <attribute name="onClick"><![CDATA[ lbEvento.getItems().clear(); for(int i=0;i<40;i++){ Listitem li = new Listitem(); li.setLabel("AAA"+i); li.setParent(lbEvento); } ]]></attribute> </button> <listbox id="lbEvento" multiple="true" rows="5" mold="paging" pageSize="5"> <listhead> <listheader label="Evento" /> </listhead> <listitem label="A"/><listitem label="A"/><listitem label="A"/><listitem label="A"/> <listitem label="A"/><listitem label="A"/><listitem label="A"/><listitem label="A"/><listitem label="A"/> <listitem label="A"/><listitem label="A"/><listitem label="A"/><listitem label="A"/><listitem label="A"/> </listbox> </window>
Thanks Dennis.
I double-check my Zk jars to be sure they are 3.52 and they are.
You code works oK too but my problem persist, so I debug my code and I find put the problem is in the line
lbEvento.getItems().clear();
Then in my java code I did:
lbEvento.setMold(""); lbEvento.getItems().clear(); for (EventoBean eb : eventoList) { Listitem li = new Listitem(); li.setValue(eb); li.appendChild(new Listcell(eb.getNombre())); li.appendChild(new Listcell(String.valueOf(eb.getPrioridad()))); li.appendChild(new Listcell(eb.getFechaInicioAsString())); lbEvento.appendChild(li); li.addEventListener(Events.ON_DOUBLE_CLICK, new EventListener() { public void onEvent(Event event) throws Exception { onEdit(event); } }); } lbEvento.setMold("paging");
And now it is working OK... :-)
very strange, in past of my experience , I did the stupid listbox.getChildren().clear(); in paging mold.
:(
Asked: 2009-02-02 20:43:21 +0800
Seen: 206 times
Last updated: Feb 06 '09