0

Listbox taking huge amount of time to display with data

asked 2011-09-12 04:52:51 +0800

wangditashi gravatar image wangditashi
12

Hi All,

I am a newbie with ZK. I upgraded an already existing application from ZK-3.6.x to ZK-5.0.8 recently and I have run into an issue with listbox taking lot of time to load data. Any pointers on how to fasten this listbox loading. With zk 3.x it was pretty fast but with zk-5.0.8 its dead slow.

-wangditashi

delete flag offensive retag edit

6 Replies

Sort by ยป oldest newest

answered 2011-09-12 07:17:00 +0800

madruga0315 gravatar image madruga0315 flag of Brazil
937 2 12

Hi,

I also got a severe performance problem when upgrading to ZK 5.0.8.
Found out that the performance problem was on using the hlayout component inside a listcell. Switchint to hbox solved for me.

More info at this thread

link publish delete flag offensive edit

answered 2011-09-13 04:33:31 +0800

wangditashi gravatar image wangditashi
12

Thanks for the help. But we are not using any hlayout component in our application as it was introduced in versions later than 3.x.
Here is the code snippet that we are using to load the listbox with the data ---

        <listbox id="listboxAlerts" fixedLayout="true" rows="4">
		<listhead>
				<listheader id="listheaderAlertCode" label="Alert Code" sort="auto" style="width:12%;"/>
				<listheader id="listheaderDescription" sort="auto" style="width:58%;"/>
				<listheader id="listheaderValidate" sort="auto" style="width:10%;"/>
				<listheader id="listheaderNotifyService" sort="auto" style="width:10%;"/>
				<listheader id="listheaderNotifyCustomer" sort="auto" style="width:10%;"/>
		</listhead>
	</listbox>

and the java code to add listitems and listcells on the runtime...


                Listbox listboxModels = getListbox("listboxModels");

		Listitem listitem = new Listitem();
		listitem.setValue(model);
		createListCell(model.getName(), listitem);
		listitem.setParent(listboxModels);

                public Listcell createListCell(String label, Listitem parent) {
		      Listcell listcell = new Listcell();
   		      listcell.setLabel(label);
		      listcell.setParent(parent);
		      return listcell;
	}

link publish delete flag offensive edit

answered 2011-09-13 04:41:56 +0800

adrianf gravatar image adrianf
9

updated 2011-09-13 04:43:57 +0800

I also got a similar Issue.
I wanted to migrate an existing ZK Application to ZK5 (from 3.5.2).
With 3.5 the listbox reloading was instant. With ZK5 (all versions up to 5.0.8 tested), already with about 200 items in 2 listboxes, the rendering takes up to 10 seconds. Tested with IE, Firefox and Chrome. All very slow.

Initial Page-Loading is okay though. Only the reloading after changing takes ages.
Here is a small dummy Application showing the problem.

INDEX.ZUL

<?page title="Auto Generated index.zul"?>
<window border="normal" use="test.TestWindow" apply="test.TestComposer"
	width="100%" contentStyle="overflow:auto;position:relative"
	height="698px" id="win" forward="onCreate=onPageCreate">
	<tabbox id="tabBox">
		<tabs>
			<tab label="label.selection" closable="false" />
		</tabs>
		<tabpanels>
			<tabpanel>
				<groupbox  mold="3d"
					id="input">
				</groupbox>
			</tabpanel>
		</tabpanels>
	</tabbox>
</window>

test.TestWindow.java

package test;

import org.zkoss.zk.ui.Components;
import org.zkoss.zk.ui.ext.AfterCompose;
import org.zkoss.zul.Groupbox;
import org.zkoss.zul.Window;

public class TestWindow extends Window implements AfterCompose {
    private static final long serialVersionUID = 8958160798085756425L;
    private Groupbox          input;

    public void setInput(Groupbox input) {
        this.input = input;
    }

    public Groupbox getInput() {
        return input;
    }

    public void afterCompose() {
        Components.wireVariables(this, this);
    }
}

test.TestComposer.java

package test;

import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.ForwardEvent;
import org.zkoss.zk.ui.util.GenericAutowireComposer;
import org.zkoss.zul.Caption;
import org.zkoss.zul.Listbox;
import org.zkoss.zul.Separator;

public class TestComposer extends GenericAutowireComposer {
    private static final long serialVersionUID = -5425478484825293469L;
    private TestWindow        win;

    public void onCreate(Event event) {
        win = (TestWindow) self;
        win.getInput().appendChild(new Caption("Test"));
        Listbox l1 = createListboxControl();
        l1.setId("my_listbox_1");
        win.getInput().appendChild(l1);
        win.getInput().appendChild(new Separator());
        Listbox l2 = createListboxControl();
        l2.setId("my_listbox_2");
        win.getInput().appendChild(l2);
    }

    public void onParameterChanged(Event event) {
        if (!(event instanceof ForwardEvent)) {
            return;
        }
        final Event origin = ((ForwardEvent) event).getOrigin();
        final String compId = origin.getTarget().getId();
        if (origin.getTarget() instanceof Listbox) {
            listboxChanged(origin);
        }
    }

    private void listboxChanged(Event origin) {
        final Listbox listbox = (Listbox) origin.getTarget();
        addListboxItems(listbox);
    }

    private Listbox createListboxControl() {
        final Listbox listbox = new Listbox();

        listbox.setRows(1);
        listbox.setMold("select");

        listbox.addForward("onSelect", self, "onParameterChanged");
        addListboxItems(listbox);
        return listbox;
    }

    private void addListboxItems(final Listbox listbox) {
        listbox.getChildren().clear();
        for (int i = 0; i < 200; i++) {
            listbox.appendItem(Math.random() + "", Math.random() + "");
        }
    }
}

link publish delete flag offensive edit

answered 2011-09-18 19:58:19 +0800

samchuang gravatar image samchuang
4084 4

Hi

refer to the thread, it mentioned, the freshly version fixed the issue, you could try to download and test it

link publish delete flag offensive edit

answered 2011-09-20 02:54:17 +0800

wangditashi gravatar image wangditashi
12

I downloaded 5.0.9 build but the performance issue still persists. The same code used to instantly load data in the listbox with zk 3.6 build but the same throws script errors on 5.0.8/9 build. I made some minor changes to do away with the script errors but the performance is still very bad.
The new build 5.0.9 didn't help much in this case.

link publish delete flag offensive edit

answered 2011-09-25 19:44:49 +0800

samchuang gravatar image samchuang
4084 4

Hi, @wangditashi

Could you show your sample code using ZK Fiddle ?

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-09-12 04:52:51 +0800

Seen: 357 times

Last updated: Sep 25 '11

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