0

Listbox refresh problem

asked 2010-02-15 04:13:12 +0800

satshcool gravatar image satshcool
39

Hello everyone,
I use a ListModelList to populate a Listbox with over 1000 records, my problem is that the treatment is very slow and it affects the display of the Listbox that displays nothing until completion of treatment. My question is: how to refresh the Listbox in the browser whenever I add 10 items in ListModelList server side?
Thank you for your help

delete flag offensive retag edit

4 Replies

Sort by ยป oldest newest

answered 2010-02-15 06:34:23 +0800

satshcool gravatar image satshcool
39

updated 2010-02-15 06:37:56 +0800

Here my control ans zul code

//*************************************************** 
public class ContolerlistboxEvent extends GenericForwardComposer {

Listbox explorerListbox;

public void doAfterCompose(Component comp) throws Exception {
		super.doAfterCompose(comp);
	//......
	//......

	List datalist = new ArrayList();
	class DataListRender implements ListitemRenderer {
		public void render(Listitem li, Object data) {
			//code rendering listbox
			// ....
		}
	}
	explorerListbox.setItemRenderer(new DataListRender());

	class DataModel extends ListModelList {
		public DataModel(List list) {
			super(list, true);
		}
		public void addListDataListener(String onChange,
				ListDataListener listDataListener) {
			//code onChange
			// ....
			
		}
		public void sort(Comparator cmpr, boolean ascending) {
			//code comparator
			// ....
			
		}

		
	}
	explorerListbox.setModel(new DataModel(datalist));

	Thread DataListThread = new Thread("DataListThread") {
		public void run() {
			try {
				// Here, I populate datalist
				initData(datalist);	
			} catch (IOException e) {
				e.printStackTrace();
			}	
		}
	};
			
	new Thread () {
		public void run() {
			try {
				DataListThread.start();
				while (datalist.size()<1000) {
					if (datalist.size() % 10 == 0) 
						// TODO Auto-generated, Here, I want to refresh the explorerListbox, how can I do this ??
					this.sleep(10000);
				}
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}.start();
	//........
	//........
}

}
//*************************************************** 

//Here my zul code
//*************************************************** 
<window id="main" apply="org.satshcool.ui.ContolerlistboxEvent">
<listbox id="explorerListbox">
....
....
//*************************************************** 

thank you for your suggestion

link publish delete flag offensive edit

answered 2010-02-15 06:41:28 +0800

TOtte gravatar image TOtte
93 2

Hi,
I don't know if you already had a look at this, but I believe it should be helpfull:
http://docs.zkoss.org/wiki/Grids,_Trees_and_Listbox#Live_Data

I didn't try something like that myself yet, but this seems to be the way to do it.

link publish delete flag offensive edit

answered 2010-02-15 07:01:04 +0800

satshcool gravatar image satshcool
39

thank you for your post. but there is no answer to my question on this page :(, the problem is : how can I refresh explorerListbox during treatment initData(datalist);

link publish delete flag offensive edit

answered 2010-02-17 08:03:59 +0800

satshcool gravatar image satshcool
39

I solved my problem by treating a range of registration on demand, and synchronizing the PAGING with my data source.

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: 2010-02-15 04:13:12 +0800

Seen: 841 times

Last updated: Feb 17 '10

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