0

onCreate Listbox Render on Demand

asked 2011-03-17 06:41:57 +0800

Neus gravatar image Neus
1415 14

Hi,

I wanto to fill a Listbox on window onCreate event. If i set listbox's attribute Render on Demand to true the data doesn't appears.

Zul:

<window id="Ventana" title="new page title" border="normal" apply="PruebaListbox.PruebaModelListbox">
	<listbox id="LB" height="600px" mold="paging" autopaging="true">
	<custom-attributes org.zkoss.zul.listbox.rod="true"/>
		<listhead>
			<listheader/>
		</listhead>
	</listbox>
</window>

Java class:

public void onCreate$Ventana(Event event){
        List<String>Lista = new ArrayList<String>();
        for(int i=0;i<3000;i++){
		Lista.add("item " + i);
	}
	ListboxRenderer renderer = new ListboxRenderer();
	List model = new ListModelList(Lista);
	LB.setModel((ListModel) model);
	LB.setItemRenderer(new ListitemRenderer(){
             String ary = (String)data;
             Listcell lc = new Listcell (ary);   
             item.appendChild(lc);
       });
}

Can anyone tell me why?

Thank you.

delete flag offensive retag edit

4 Replies

Sort by ยป oldest newest

answered 2011-03-17 06:56:20 +0800

yaryan997 gravatar image yaryan997
210 2

@Neus.

you can TRY WITH THIS..

protected Listbox LB;

onCreate$Ventana(Event evt) throws Exception 
{
this.loadlistBox();

}


public void loadlistBox()
{
	List<String>Lista = new ArrayList<String>();
        for(int i=0;i<3000;i++){
		Lista.add("item " + i);
	}

	ListModelList listModelList = new ListModelList();
	listModelList.addAll(Lista);
	LB.setModel(listModelList);
	LB.setItemRender(this);
}



public void render(Listitem listItem, Object data) throws Exception {
		// TODO Auto-generated method stub
		Map map = (Map) data;
		new Listcell(map.get("clg_seller_id").toString()).setParent(listItem);
	}



link publish delete flag offensive edit

answered 2011-03-17 09:42:46 +0800

Neus gravatar image Neus
1415 14

Id doesn't work neither.
If I navigate throw pages the items appears. But the first time is loaded the listbox doesn't show data

link publish delete flag offensive edit

answered 2011-03-17 10:52:47 +0800

yaryan997 gravatar image yaryan997
210 2

@Neus

so can you make use of doAfterCompose(Event event) {}

it is the first method that is executed when the zul page loades.
Hope this may help you well


Best Regards
Yogendra

link publish delete flag offensive edit

answered 2011-03-17 11:13:48 +0800

Neus gravatar image Neus
1415 14

It works great, thank you :)

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: 2011-03-17 06:41:57 +0800

Seen: 585 times

Last updated: Mar 17 '11

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