-
FEATURED COMPONENTS
First time here? Check out the FAQ!
zkfan
7 days ago
199.64.0.252
Delete
Has anyone tried to tackle this Million Record Challenge? It will be a good exercise for someone with time on his hands or for the ZK developers to show off their product.
AA hkn
5 days ago
82.139.196.21
Delete
Hi everybody!
Even I think this competition isn't really fair I found it interesting enough to spend some with it. I just make use of a paging listbox with four columns. The implementation is simple and stupid as I did no special optimization. To be honest: 1.000.000 seem impossible with this approach. I just tested up to 50.000 successfully. May an ItemRender will speed up loading? I have no idea... Maybe one of the ZK gurus can show how to speed it up! ;-)
And by the way: The Flex example is really impressive!
/ Horstsdfgsdfg
Maybe someone is interested to improve my quickshot:
The ZUL file:
<?page id="mio" title="1 Million Records" cacheable="false"
language="xul/html" zscriptLanguage="Java" contentType="text/html;charset=UTF-8"?>
<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit"?>
<zk xmlns="http://www.zkoss.org/2005/zul"
xmlns:h="http://www.w3.org/1999/xhtml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.zkoss.org/2005/zul http://www.zkoss.org/2005/zul/zul.xsd">
<window title="My First Window" border="normal" width="600px"
height="95%" id="win" use="Crtl">
<hbox>
<combobox id="cb" readonly="true" >
<comboitem id="cb1" value="1" label="10.000" />
<comboitem id="cb2" value="2" label="20.000" />
<comboitem id="cb3" value="3" label="30.000" />
</combobox>
</hbox>
<listbox id="lb" width="560px" height="550px" mold="paging" pageSize="100" >
<listhead>
<listheader label="col 1" sort="auto" />
<listheader label="col 2" sort="auto" />
<listheader label="col 3" sort="auto" />
<listheader label="col 4" sort="auto" />
</listhead>
<listitem self="@{each=itm}">
<listcell label="@{itm.a}" />
<listcell label="@{itm.b}" />
<listcell label="@{itm.c}" />
<listcell label="@{itm.d}" />
</listitem>
</listbox>
</window>
</zk>
And here is my backend java class: Crtl.java
//------------------------------------------ START Crtl.java -----------
import java.util.Random;
import org.zkoss.zk.ui.Components;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.ext.AfterCompose;
import org.zkoss.zkplus.databind.AnnotateDataBinder;
import org.zkoss.zul.Combobox;
import org.zkoss.zul.ListModelList;
import org.zkoss.zul.Listbox;
import org.zkoss.zul.Window;
public class Crtl extends Window implements AfterCompose {
protected AnnotateDataBinder binder;
protected Combobox cb;
protected Window win;
protected Listbox lb;
final static int anz1 = 10000;
final static int anz2 = 20000;
final static int anz3 = 30000;
final static ListModelList data1 = new ListModelList(anz1);
final static ListModelList data2 = new ListModelList(anz2);
final static ListModelList data3 = new ListModelList(anz3);
Random r;
public void onCreate$win(Event e) throws Exception {
binder = new AnnotateDataBinder(win);
// CfgConfigsDAO dao = new CfgConfigsDAO();
// cfg.setAttribute("dao",dao);
binder.loadAll();
}
// @Override
public void afterCompose() {
// wire variables
Components.wireVariables(this, this);
// NO need to register onXxx event listeners auto forward
Components.addForwards(this, this);
}
public class ListData implements Comparable<ListData>{
String a;
String b;
String c;
String d;
public ListData(String a, String b, String c, String d) {
this.a = a;
this.b = b;
this.c = c;
this.d = d;
}
public String getA() {
return a;
}
public void setA(String a) {
this.a = a;
}
public String getB() {
return b;
}
public void setB(String b) {
this.b = b;
}
public String getC() {
return c;
}
public void setC(String c) {
this.c = c;
}
public String getD() {
return d;
}
public void setD(String d) {
this.d = d;
}
@Override
public int compareTo(ListData o) {
return this.a.compareTo(o.getA());
}
}
private void create(ListModelList data, int anz) {
int j = 0;
for (int i = 1; i <= anz; i++) {
j++;
if (j == 1000) {
System.out.println("i=" + i);
j = 0;
}
long l = r.nextLong();
String a = String.format("" + i + " - %1$x", l);
l = r.nextLong();
String b = String.format("%1$x", l);
l = r.nextLong();
String c = String.format("%1$x", l);
l = r.nextLong();
String d = String.format("%1$x", l);
ListData o = new ListData(a, b, c, d);
data.add(o);
}
}
public Crtl() {
super();
r = new Random(5343336);
if (data1.isEmpty()) {
System.out.println("Start");
create(data1, anz1);
System.out.println("Done1");
create(data2, anz2);
System.out.println("Done2");
create(data3, anz3);
System.out.println("Done3");
}
}
public void onSelect$cb(Event ev) throws InterruptedException {
System.out.println("SELECT " + cb.getValue());
lb.setModel(getData());
}
public ListModelList getData() {
if (cb.getSelectedItem() == null)
return new ListModelList();
String iv = (String) cb.getSelectedItem().getValue();
System.out.println("get DATA " + iv);
if (iv.equalsIgnoreCase("1")) {
System.out.println("anzahl1=" + data1.getSize());
return data1;
} else if (iv.equalsIgnoreCase("2")) {
System.out.println("anzahl2=" + data2.getSize());
return data2;
} else if (iv.equalsIgnoreCase("3")) {
System.out.println("anzahl3=" + data3.getSize());
return data3;
}
return new ListModelList();
}
}
//------------------------------------------ END Crtl.java -----------
henrichen
5 days ago
118.160.232.60
Delete
Please see this smalltalk.
http://www.zkoss.org/smalltalks/loadondemand/
AA hkn
4 days ago
82.139.196.21
Delete
Hello Henri,
yes thanks for that hint. My naive expectation was that when I usesdfgsfg
a listbox with mold="paging" and a model object of ListModel* or whatever
(here ListModelList) dfgthat zk does this automaticaly.
When working with a sql database it makes sense to control the paging
by program as this can be linked to SELECT phrase "limit row_Start to row_end"
but when using a list of POJOs it would be great if zk can do this for us.
kind regards
Horst
zkfan
4 days ago
75.80.131.243
Delete
henri's solution is not germane. you have to be able to load and sort and display the records in a short time, with, of course, no need to display all the records at the same time.
AA hkn
3 days ago
82.139.196.21sfd
Delete
Hello zkfan!
Yes and no, zk has a server centric approach. So solutions need to be different, and for zk you have to implement sorting etc and some kind of paging. When I try to load a really large number of records while I try to keep my records in memory I get some out of memory exceptions even if I assign the jvm plenty of mem (about 2GB). Further, my FF collects memory like hell. The Flex speed is really impressive. Nevertheless zk has advantages when the data is read from databases and with databinding it is really great.
So I don't really thing that the approaches are comparable, but
First: paging as described in the mentioned smalltalk needs to much coding if the data is stored in a list of pojos. That should work automatically.
Second: Why do I need the paging mold. The scrollbar events are sufficient to calculate the visible part in a list box. Sorting of a pojo list requires almost nothing if the getters return values are of type string, int, float etc. So the browser just needs to hold the visible part and the Listbox would delive a server centric solution which is comparable to the Flex solution.
May I find some time to implement this - christmass is coming soon :-)
Horst
ZK Forum
Welcome: robert lee
asdfsdf
Administration | Logout | Sign Up |
tag:Tom
tag:Henri
tag:Jim
tag:Robbie
tag:Jumper
tag:Ian
tag:Jean
tag:Dennis
tag:Ivan
tag:Charles
tag:Amy
tag:Robert
tag:David
tag:Update
tag:Activity
tag:SmallTalk
tag:Release
tag:Solved
tag:Bug
tag:Feature
tag:Question
tag:Info
tag:FreeTalk
tag:Suggestion
tag:Beginner
tag:intermediate
tag:Advanced
tag:ZK_core
tag:ZK_Forum
tag:ZK_Studio
tag:ZK_SpreadSheet
tag:ZK_Component
tag:Style
tag:Compatibility
tag:Document
tag:Philosophy
tag:Flyworld
tag:ZK_forge
tag:Peter
Search
Advanced Search
Forum Home
Start a New Thread
ご要望
5
サポート
16
お知らせ
11
管理者へ
1
練習コーナー
4
Help
4915
General
584
Announce
102
Install
81
ZK Studio
24
Forum Bug
6
Forum Feature
21
建议
59
求助
156
公告
11
站务
6
新手测试
23
Users
0
Messageboard
70
All
6095
Post:
Forum Bugs
Forum Features
ZK Bugs
ZK Features
ZK Studio Bugs
ZK Studio Features
新手测试 >>
test
Edit Tag
1 Messages
/ 1
robertlee
26 seconds ago
220.133.44.37
Edit Delete
zkfan
7 days ago
199.64.0.252
Delete
Has anyone tried to tackle this Million Record Challenge? It will be a good exercise for someone with time on his hands or for the ZK developers to show off their product.
AA hkn
5 days ago
82.139.196.21
Delete
Hi everybody!
Even I think this competition isn't really fair I found it interesting enough to spend some with it. I just make use of a paging listbox with four columns. The implementation is simple and stupid as I did no special optimization. To be honest: 1.000.000 seem impossible with this approach. I just tested up to 50.000 successfully. May an ItemRender will speed up loading? I have no idea... Maybe one of the ZK gurus can show how to speed it up! ;-)
And by the way: The Flex example is really impressive!
/ Horst
Maybe someone is interested to improve my quickshot:
The ZUL file:
<?page id="mio" title="1 Million Records" cacheable="false"
language="xul/html" zscriptLanguage="Java" contentType="text/html;charset=UTF-8"?>
<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit"?>
<zk xmlns="http://www.zkoss.org/2005/zul"
xmlns:h="http://www.w3.org/1999/xhtml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.zkoss.org/2005/zul http://www.zkoss.org/2005/zul/zul.xsd">
<window title="My First Window" border="normal" width="600px"
height="95%" id="win" use="Crtl">
<hbox>
<combobox id="cb" readonly="true" >
<comboitem id="cb1" value="1" label="10.000" />
<comboitem id="cb2" value="2" label="20.000" />
<comboitem id="cb3" value="3" label="30.000" />
</combobox>
</hbox>
<listbox id="lb" width="560px" height="550px" mold="paging" pageSize="100" >
<listhead>
<listheader label="col 1" sort="auto" />
<listheader label="col 2" sort="auto" />
<listheader label="col 3" sort="auto" />
<listheader label="col 4" sort="auto" />
</listhead>
<listitem self="@{each=itm}">
<listcellasdfasdfasabel="@{itm.a}" />
<listcell label="@{itm.b}" />
<ldf>
</window>sdfasdfa
</zk>
And here is my backend java class: Crtl.java
//------------------------------------------ START Crtl.java -----------
import java.util.Random;
import org.zkoss.zk.ui.Components;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.ext.AfterCompose;
import org.zkoss.zkplus.databind.AnnotateDataBinder;
import org.zkoss.zul.Combobox;
import org.zkoss.zul.ListModelList;
import org.zkoss.zul.Listbox;
import org.zkoss.zul.Window;
public class Crtl extends Window implements AfterCompose {
protected AnnotateDataBinder binder;
protected Combobox cb;
protected Window win;
protected Listbox lb;
final static int anz1 = 10000;
final static int anz2 = 20000;
final static int anz3 = 30000;
final static ListModelList data1 = new ListModelList(anz1);
final static ListModelList data2 = new ListModelList(anz2);
final static ListModelList data3 = new ListModelList(anz3);
Random r;
public void onCreate$win(Event e) throws Exception {
binder = new AnnotateDataBinder(win);
// CfgConfigsDAO dao = new CfgConfigsDAO();
// cfg.setAttribute("dao",dao);
binder.loadAll();
}
// @Override
public void afterCompose() {
// wire variables
Components.wireVariables(this, this);
// NO need to register onXxx event listeners auto forward
Components.addForwards(this, this);
}
public class ListData implements Comparable<ListData>{
String a;
String b;
String c;
String d;
public ListData(String a, String b, String c, String d) {
this.a = a;
this.b = b;
this.c = c;
this.d = d;
}
public String getA() {
return a;
}
public void setA(String a) {
this.a = a;
}
public String getB() {
return b;
}
public void setB(String b) {
this.b = b;
}
public String getC() {
return c;
}
public void setC(String c) {
this.c = c;
}
public String getD() {
return d;
}
public void setD(String d) {
this.d = d;
}
@Override
public int compareTo(ListData o) {
return this.a.compareTo(o.getA());
}
}
private void create(ListModelList data, int anz) {
int j = 0;
for (int i = 1; i <= anz; i++) {
j++;
if (j == 1000) {
System.out.println("i=" + i);
j = 0;
}
long l = r.nextLong();
String a = String.format("" + i + " - %1$x", l);
l = r.nextLong();
String b = String.format("%1$x", l);
l = r.nextLong();
String c = String.format("%1$x", l);
l = r.nextLong();
String d = String.format("%1$x", l);
ListData o = new ListData(a, b, c, d);
data.add(o);
}
}
public Crtl() {
super();
r = new Random(5343336);
if (data1.isEmpty()) {
System.out.println("Start");
create(data1, anz1);
System.out.println("Done1");
create(data2, anz2);
System.out.println("Done2");
create(data3, anz3);
System.out.println("Done3");
}
}
public void onSelect$cb(Event ev) throws InterruptedException {
System.out.println("SELECT " + cb.getValue());
lb.setModel(getData());
}
public ListModelList getData() {
if (cb.getSelectedItem() == null)
return new ListModelList();
String iv = (String) cb.getSelectedItem().getValue();
System.out.println("get DATA " + iv);
if (iv.equalsIgnoreCase("1")) {
System.out.println("anzahl1=" + data1.getSize());
return data1;
} else if (iv.equalsIgnoreCase("2")) {
System.out.println("anzahl2=" + data2.getSize());
return data2;
} else if (iv.equalsIgnoreCase("3")) {
System.out.println("anzahl3=" + data3.getSize());
return data3;
}
return new ListModelList();
}
}
//------------------------------------------ END Crtl.java -----------
henrichen
5 days ago
118.160.232.60
Delete
Please see this smalltalk.
http://www.zkoss.org/smalltalks/loadondemand/
AA hkn
4 days ago
82.139.196.21
Delete
Hello Henri,
yes thanks for that hint. My nsdfsdfsdfsfssfst makes sense to control the paging
by program as this can be linked to SELECT phrase "limit row_Start to row_end"
but when using a list of POJOs it would be great if zk can do this for us.
kind regards
Horstsdfsdf
zkfan
4 days ago
75.80.131.243
dsdf
Delete
henri's solution is not germane. you have to be able to load and sort and display the records in a short time, with, of course, no need to display all the records at the same time.
AA hkn
3 days ago
82.139.196.21
Delete
Hello zkfan!
Yes and no, zk has a server centric approach. So solutions need to be different, and for zk you have to implement sorting etc and some kind of paging. When I try to load a really large number of records while I try to keep my records in memory I get some out of memory exceptions even if I assign the jvm plenty of mem (about 2GB). Further, my FF collects memory like hell. The Flex speed is really impressive. Nevertheless zk has advantages when the data is read from databases and with databinding it is really great.
So I don't really thing that the approaches are comparable, but
First: paging as described in the mentioned smalltalk needs to much coding if the data is stored in a list of pojos. That should work automatically.
Second: Why do I need the paging mold. The scrollbar events are sufficient to calculate the visible part in a list box. Sorting of a pojo list requires almost nothing if the getters return values are of type string, int, float etc. So the browser just needs to hold the visible part and the Listbox would delive a server centric solution which is comparable to the Flex solution.
May I find some time to implement this - christmass is coming soon :-)
Horst
/ 1
1 Messages
Message
* Edit
* Preview
*
Bold textItalic textUnderLine textSource CodeExternal LinkHorizontal ruler
Post Comment
Resize
Cancel and Go Back
Tags:
Tom
Henri
Jim
Robbie
Jumper
Ian
Jean
Dennis
Ivan
Charles
Amy
Robert
David
Update
Activity
SmallTalk
Release
Solved
Bug
Feature
Question
Info
FreeTalk
Suggestion
Beginner
intermediate
Advanced
ZK_core
ZK_Forum
ZK_Studio
ZK_SpreadSheet
ZK_Component
Style
Compatibility
Document
Philosophy
Flyworld
ZK_forge
Peter
Add Remove
Contact us Forum Archives
Zorum Version 1.2.1 Copyright © 2005-2008 Potix Corporation. All rights reserved.
Hello zkfan!
Yes and no, zk has a server centric approach. So solutions need to be different, and for zk you have to implement sorting etc and some kind of paging. When I try to load a really large number of records while I try to keep my records in memory I get some asdfasdfasdfd
So I don't really thing that the approaches are comparablesdsdfsfsf, but
First: paging as described in the mentioned smalltalk needs to much coding if the data is stored in a list of pojos. That should work automatically.
Second: Why do I need the paging mold. The scrollbar events are sufficient to calculate the visible part in a list box. Sorting of a pojo list requires almost nothing if the getters return values are of type string, int, float etc. So the browser just needs to hold the visible part and the Listbox would delive a server centric solution which is comparable to the Flex solution.
May I find some time to implement this - christmass is coming soon :-)
Horst
Hello zdawdwdserver centric approach. So solutions need to be different, and for zk you have to implement sorting etc and some kind of paging. When I try to load a really large number of records while I try to keep my records in memory I gewdsome owrom datwd with databinddng it is really great.
So I don't really thing that the approaches are comparable, but
First: paging as described in the mentioned smalltalk needs to much coding if the data is stored in a list of pojos. That should work automatically.
Second: Why do I need the paging mold. The scrollbar events are sufficient to calculate the visible part in a list box. Sorting of a pojo list requires almost nothing if the getters return values are of type string, int, float etc. So the browser just needs to hold the visible part and the Listbox would delive a server centric solution which is comparable to the Flex solution.
May I find some time to implement this - cdadhristmass is coming soon :-)
awdad aw 23556%^&*()_)(*&^%$#
Horst
Hi everybody!
Even I think this competition isn't really fair I found it interesting enough to spend some with it. I just make use of a paging listbox with four columns. The implementation is simple and stupid as I did no special optimization. To be honest: 1.000.000 seem impossible with this approach. I just tested up to 50.000 successfully. May an ItemRender will speed up loading? I have no idea... Maybe one of the ZK gurus can show how to speed it up! ;-)
And by the way: The Flex example is really impressive!
/ Horst
Maybe someone is interested to improve my quickshot:
The ZUL file:
<?page id="mio" title="1 Million Records" cacheable="false"
language="xul/html" zscriptLanguage="Java" contentType="text/html;charset=UTF-8"?>
<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit"?>
<zk xmlns="http://www.zkoss.org/2005/zul"
xmlns:h="http://www.w3.org/1999/xhtml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.zkoss.org/2005/zul http://www.zkoss.org/2005/zul/zul.xsd">
<window title="My First Window" border="normal" width="600px"
height="95%" id="win" use="Crtl">
<hbox>
<combobox id="cb" readonly="true" >
<comboitem id="cb1" value="1" label="10.000" />
<comboitem id="cb2" value="2" label="20.000" />
<comboitem id="cb3" value="3" label="30.000" />
</combobox>
</hbox>
<listbox id="lb" width="560px" height="550px" mold="paging" pageSize="100" >
<listhead>
<listheader label="col 1" sort="auto" />
<listheader label="col 2" sort="auto" />
<listheader label="col 3" sort="auto" />
<listheader label="col 4" sort="auto" />
</listhead>
<listitem self="@{each=itm}">
<listcell label="@{itm.a}" />
<listcell label="@{itm.b}" />
<listcell label="@{itm.c}" />
<listcell label="@{itm.d}" />
</listitem>
</listbox>
</window>
</zk>
And here is my backend java class: Crtl.java
//------------------------------------------ START Crtl.java -----------
import java.util.Random;
import org.zkoss.zk.ui.Components;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.ext.AfterCompose;
import org.zkoss.zkplus.databind.AnnotateDataBinder;
import org.zkoss.zul.Combobox;
import org.zkoss.zul.ListModelList;
import org.zkoss.zul.Listbox;
import org.zkoss.zul.Window;
public class Crtl extends Window implements AfterCompose {
protected AnnotateDataBinder binder;
protected Combobox cb;
protected Window win;
protected Listbox lb;
final static int anz1 = 10000;
final static int anz2 = 20000;
final static int anz3 = 30000;
final static ListModelList data1 = new ListModelList(anz1);
final static ListModelList data2 = new ListModelList(anz2);
final static ListModelList data3 = new ListModelList(anz3);
Random r;
public void onCreate$win(Event e) throws Exception {
binder = new AnnotateDataBinder(win);
// CfgConfigsDAO dao = new CfgConfigsDAO();
// cfg.setAttribute("dao",dao);
binder.loadAll();
}
// @Override
public void afterCompose() {
// wire variables
Components.wireVariables(this, this);
// NO need to register onXxx event listeners auto forward
Components.addForwards(this, this);
}
public class ListData implements Comparable<ListData>{
String a;
String b;
String c;
String d;
public ListData(String a, String b, String c, String d) {
this.a = a;
this.b = b;
this.c = c;
this.d = d;
}
public String getA() {
return a;
}
public void setA(String a) {
this.a = a;
}
public String getB() {
return b;
}
public void setB(String b) {
this.b = b;
}
public String getC() {
return c;
}
public void setC(String c) {
this.c = c;
}
public String getD() {
return d;
}
public void setD(String d) {
this.d = d;
}
@Override
public int compareTo(ListData o) {
return this.a.compareTo(o.getA());
}
}
private void create(ListModelList data, int anz) {
int j = 0;
for (int i = 1; i <= anz; i++) {
j++;
if (j == 1000) {
System.out.println("i=" + i);
j = 0;
}
long l = r.nextLong();
String a = String.format("" + i + " - %1$x", l);
l = r.nextLong();
String b = String.format("%1$x", l);
l = r.nextLong();
String c = String.format("%1$x", l);
l = r.nextLong();
String d = String.format("%1$x", l);
ListData o = new ListData(a, b, c, d);
data.add(o);
}
}
public Crtl() {
super();
r = new Random(5343336);
if (data1.isEmpty()) {
System.out.println("Start");
create(data1, anz1);
System.out.println("Done1");
create(data2, anz2);
System.out.println("Done2");
create(data3, anz3);
System.out.println("Done3");
}
}
public void onSelect$cb(Event ev) throws InterruptedException {
System.out.println("SELECT " + cb.getValue());
lb.setModel(getData());
}
public ListModelList getData() {
if (cb.getSelectedItem() == null)
return new ListModelList();
String iv = (String) cb.getSelectedItem().getValue();
System.out.println("get DATA " + iv);
if (iv.equalsIgnoreCase("1")) {
System.out.println("anzahl1=" + data1.getSize());
return data1;
} else if (iv.equalsIgnoreCase("2")) {
System.out.println("anzahl2=" + data2.getSize());
return data2;
} else if (iv.equalsIgnoreCase("3")) {
System.out.println("anzahl3=" + data3.getSize());
return data3;
}
return new ListModelList();
}
}
//------------------------------------------ END Crtl.java -----------
henrichen
5 days ago
118.160.232.60
Delete
Please see this smalltalk.
Hi everybody!
Even I think this competition isn't really fair I found it interesting enough to spend some with it. I just make use of a paging listbox with four columns. The implementation is simple and stupid as I did no special optimization. Toasdfsdfssdfsdf
And by the way: The Flex exadfdfsdsdfmple is really impressive!
/ Horstsdf
Maybe someone is interested to improve my quickshot:
The ZUL file:sdfsfs
<?page id="mio" title="1 Million Records" cacheable="false"
language="xul/html" zscriptLanguage="Java" contentType="text/html;charset=UTF-8"?>
<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit"?>
<zk xmlns="http://www.zkoss.orfsdg/2005/zul"
xmlns:h="http://www.w3.org/1999/xhtml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.zkoss.org/2005/zul http://www.zkoss.org/2005/zul/zul.xsd">
<window title="My First Window" border="normal" width="600px"
height="95%" id="win" use="Crtl">
<hbox>
<combobox id="cb" readonly="tsdfsdfrue" >
<comboitem id="cb1" value="1" label="10.000" />
<comboitem id="cb2" value="2" label="20.000" />
<comboitem id="cb3" value="3" label="30.000" />
</combobox>sdfsdf
</hbox>
<listbox id="lb" width="560px" height="550px" mold="paging" pageSize="100" >
<listhead>sdfsdf
<listheader label="col 1" sort="auto" />
<listheader label="col 2" sort="auto" />
<listheader label="col 3" sort="auto" />
<listheader label="col 4" dfsdsd="auto" />
</listhead>
<listitem self="@{each=itm}">
<listcell label="@{itm.a}" />
<listcell label="@{itm.b}" />fsdfs
<listcell label="@{itm.c}" />
<listcell label="@{itm.d}" />
</listitem>
dfsdsdf
</listbox>
</window>
</zk>
And here is my backend java class: Crtl.java
//------------------------------------------ START Crtl.java -----------
import java.util.Random;
import org.zkoss.zk.ui.Components;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.ext.AfterCompose;
import org.zkoss.zkplus.databind.AnnotateDataBinder;
import org.zkoss.zul.Combobox;
import org.zkoss.zul.ListModelList;
import org.zkoss.zul.Listbox;
import org.zkoss.zul.Window;
public class Crtl extends Window implements AfterCompose {
protected AnnotateDataBinder binder;
protected Combobox cb;
protected Window win;
protected Listbox lb;
final static int anz1 = 10000;
final static int anz2 = 20000;
final static int anz3 = 30000;
final static ListModelList data1 = new ListModelList(anz1);
final static ListModelList data2 = new ListModelList(anz2);
final static ListModelList data3 = new ListModelList(anz3);
Random r;
public void onCreate$win(Event e) throws Exception {
binder = new AnnotateDataBinder(win);
// CfgConfigsDAO dao = new CfgConfigsDAO();
// cfg.setAttribute("dao",dao);
binder.loadAll();
}
// @Override
public void afterCompose() {
// wire variables
Components.wireVariables(this, this);
// NO need to register onXxx event listeners auto forward
Components.addForwards(this, this);
}
public class ListData implements Comparable<ListData>{
String a;
String b;
String c;
String d;
public ListData(String a, String b, String c, String d) {
this.a = a;
this.b = b;
this.c = c;
this.d = d;
}
public String getA() {
return a;
}
public void setA(String a) {
this.a = a;
}
public String getB() {
return b;
}
public void setB(String b) {
this.b = b;
}
public String getC() {
return c;
}
public void setC(String c) {
this.c = c;
}
public String getD() {
return d;
}
public void setD(String d) {
this.d = d;
}
@Override
public int compareTo(ListData o) {
return this.a.compareTo(o.getA());
}
}
private void create(ListModelList data, int anz) {
int j = 0;
for (int i = 1; i <= anz; i++) {
j++;
if (j == 1000) {
System.out.println("i=" + i);
j = 0;
}
long l = r.nextLong();
String a = String.format("" + i + " - %1$x", l);
l = r.nextLong();
String b = String.format("%1$x", l);
l = r.nextLong();
String c = String.format("%1$x", l);
l = r.nextLong();
String d = String.format("%1$x", l);
ListData o = new ListData(a, b, c, d);
data.add(o);
}
}
public Crtl() {
super();
r = new Random(5343336);
if (data1.isEmpty()) {
System.out.println("Start");
create(data1, anz1);
System.out.println("Done1");
create(data2, anz2);
System.out.println("Done2");
create(data3, anz3);
System.out.println("Done3");
}
}
public void onSelect$cb(Event ev) throws InterruptedException {
System.out.println("SELECT " + cb.getValue());
lb.setModel(getData());
}
public ListModelList getData() {
if (cb.getSelectedItem() == null)
return new ListModelList();
String iv = (String) cb.getSelectedItem().getValue();
System.out.println("get DATA " + iv);
if (iv.equalsIgnoreCase("1")) {
System.out.println("anzahl1=" + data1.getSize());
return data1;
} else if (iv.equalsIgnoreCase("2")) {
System.out.println("anzahl2=" + data2.getSize());
return data2;
} else if (iv.equalsIgnoreCase("3")) {
System.out.println("anzahl3=" + data3.getSize());
return data3;
}
return new ListModelList();
}
}
//------------------------------------------ END Crtl.java -----------
henrichen
5 days ago
118.160.232.60
Delete
Please see this smalltalk.
ssdfsdfsdfsd
<comboitem id="cb1" value=fsdfsdf"1" label="10.000" />
<comboitem id="cb2" value="2" label="20.000" />
<comboitem id="cb3" value="3" label="30.000" />
</combobox>
</hbox>
<listbox id="lb" width="560px" height="550px" mold="paging" pageSize="100" >
<listhead>
<listheader label="col 1" sort="auto" />
<listheader label="col 2" sort="auto" />
<listheader label="col 3" sort="auto" />
<listheader label="col 4" sort="auto" />
</listhead>
<listitem self="@{each=itm}">
<listcell label="@{itm.a}" />
<listcell label="@{itm.b}" />sdfsdfsdfsdf
<listcell label="@{itm.c}" />
<listcell label=dfsdf"@{itm.d}" />
</listitem>
</listbox>