I have a problem when implements a AbstractListModel

asked 2014-01-24 20:56:23 +0800

javikin gravatar image javikin flag of Mexico
45 2

I'm imlpements a AbstractListModel,

public class HugeDataListModel extends AbstractListModel {

private final int pageSize;
private final PageDataModel innerModel;

public HugeDataListModel(int pageSize, PageDataModel dataModel) {
    this.pageSize = pageSize;
    if (pageSize <= 0) {
        throw new IllegalArgumentException("page size should be positive > integer");
    innerModel = dataModel;

public Object getElementAt(int index) {
    int residual = index % pageSize;
    return innerModel.toPage(index / pageSize).get(residual);

public int getSize() {
    return innerModel.getTotalSize();


I have a table with 50,000 records, but i dont know why the method getSize() is call around 150,000 times

The oder code:

HugeDataListModel hdlm = new HugeDataListModel(10, new ProcesoPageDataModel(10)); lb.setModel(hdlm); lb.setItemRenderer(new ProcesoRender());


delete flag offensive retag edit

2 Answers

Sort by ยป oldest newest most voted

answered 2014-01-25 17:16:05 +0800

javikin gravatar image javikin flag of Mexico
45 2

Here is my code example:


The weird is that in my project, doesn't work, i have the problem above, the getSize is calling 3 * number rows

link publish delete flag offensive edit

answered 2014-01-27 07:46:03 +0800

chillworld gravatar image chillworld flag of Belgium
5357 4 9

When you look at github the code behind you will see that it's "normal" that getSize() is called multiple times. The only BIG problem is that zk doesn't make a difference between totalSize and size. When they do that they don't have to called it so much.(I did testing with refactoring there code). With all the evolutions that we do have more data, I see paging and implementations comming up. They have the difference between totalSize and size, so it should be in the AbstractListModel to. Even when you don't need it, its so simpel to say that totalSize is the same as size.

On the other hand, after your implemented getSize() there shouldn't be heavy code.

Greetz chill.

link publish delete flag offensive edit


I have implement the getSize(), the weird is that in zkfiddle the method is called only a few times, while in my development version, is called a lot. And the code is the same.

javikin ( 2014-01-27 17:31:40 +0800 )edit

which ZK are you using locally? (zk fiddle is runs on ZK EE) there might be performance optimizations only available in ZK EE or PE in contrast to the free CE version. I suggest to try your example with the trial version of ZK EE and see if the performance improves http://www.zkoss.org/download/zk

cor3000 ( 2014-01-28 09:45:28 +0800 )edit

I'm using ZK CE version, but i created a project only like de sample in the findle using the ZK EE and didn't work.

javikin ( 2014-01-28 16:13:06 +0800 )edit

I am confused now... you created the sample yourself and now you claim it does not work anymore?

cor3000 ( 2014-01-29 04:21:32 +0800 )edit

Using ZK EE enabling Render on Demand will greatly reduce the number of listitems created on the serverside, and and number of how often getSize is called. <custom-attributes org.zkoss.zul.listbox.rod="true" scope="page"/>

cor3000 ( 2014-01-29 04:23:23 +0800 )edit
Your answer
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

1 follower



Asked: 2014-01-24 20:56:23 +0800

Seen: 33 times

Last updated: Jan 27 '14

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