0

Live Data - Please Save Me!

asked 2006-11-17 20:46:11 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4018414

By: sduensin

I've been working on this for an entire week now...

I have a list box with 'mold="paging"'. I want to display the results of a call to a SOAP web service in this box. This much works. However, the SOAP service returns almost 4000 records. As you can imagine, this is very slow. \

I want to allow the user to page through the data and load only what is needed on-demand. I've tried everything I can think of with very little luck. I've read the forums, the small talks, the demo source code, the developer's guide, the developer's reference... I'm out of things to read!

*PLEASE* for the sake of my sanity would someone provide a complete example of how to page data in from an outside data source? I can't do all the fancy database stuff with Hibernate and such. I have to use a web service.

I'm at my wits end with this. Save me!

Thanks!

Scott (Still hanging out by my lonesome in #ZK on EFNet!)


delete flag offensive retag edit

12 Replies

Sort by ยป oldest newest

answered 2006-11-17 20:46:22 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4018416

By: sduensin

Oh yea - to make it even more interesting, this is a multiple column list box.
:-)

Scott


link publish delete flag offensive edit

answered 2006-11-20 02:48:37 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4020574

By: henrichen

If you have to get 4000 records in a whole then there is no way to improve it since the 4000 records cannot be get until it is returned. If you can get only partial of the 4000 records, then prepare an onPaging event handler that would read that partial of 4000 records and then fill them into the relative place of your ListModel.


/henri


link publish delete flag offensive edit

answered 2006-11-20 13:37:38 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4021529

By: sduensin

I can page the data in as needed. I just can't get the paging to work in ZK.
I was hoping for a complete example of how to do this.

Thanks!

Scott


link publish delete flag offensive edit

answered 2006-11-21 06:07:46 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4023053

By: henrichen

<window>
<zscript>
List items = new org.zkoss.zkdemo.userguide.BigList(1000); //a big list of Integer
int itemCount = items.size();
char[] fake = new char[itemCount];
</zscript>

<listbox id="lb" mold="paging" onPaging="doPaging(event.getActivePage())">
<listitem label="" forEach="${fake}"/>
</listbox>

<zscript>
int pagesz = lb.getPageSize();
void doPaging(int pageno) {
//calculate the range to be displayed
int indexbegin = pageno * pagesz;
int indexend = indexbegin+pagesz;
if (indexend > itemCount)
indexend = itemCount;

//get the paging data from datasource
// and populate the Listbox of that paging range
// here can do some book keeping to avoid load twice...
lbs = lb.getItems()
for(int j = indexbegin; j < indexend; ++j) {
((Listitem)lbs.get(j)).setLabel(""+items.get(j));
}
}
doPaging(0); //initialize page 0
</zscript>
</window>


/henri

link publish delete flag offensive edit

answered 2006-11-22 19:33:15 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4026397

By: sduensin

Henri, you're amazing. I'm back on track! ** THANK YOU! **

Scott


link publish delete flag offensive edit

answered 2007-04-27 09:35:29 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4283693

By: jasonhao

I don't think it make sense. If I have 1,000,000 record in database, I have to prepare 1,000,000 fake list items. In fact, the developer should only care about the list items which are visible. That is 20 list items if the page size is 20.

link publish delete flag offensive edit

answered 2007-05-01 03:26:51 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4288653

By: henrichen

Well, the example is the "easy" way for not too long contents.

For special case, e.g. 1,000,000 records. You might have to use a separate Paging component or implement your own Paginal component. And then catch the onPaging event to fetch proper data out and "stuff" into the Grid or Listbox.

/henri

link publish delete flag offensive edit

answered 2007-06-04 03:51:18 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4342450

By: gback

> And then catch the onPaging event to fetch proper data out and "stuff"
> into
the Grid or Listbox

Could you be more specific about how you "stuff" data into the grid or listbox?

The developer's guide only uses pseudocode "new Viewer()..." so it's not clear which methods have to be used to decide which items should be rendered for the page that is currently visible.

Could you give an example of how to render, say items n.. n+pgsize-1 where n is the number of the page being displayed and pgsize if the paging size?

Thanks!



link publish delete flag offensive edit

answered 2007-06-04 06:27:42 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4342531

By: gback

Specifically, I attempted to create pageSize listitems+listcells, and then to manipulate them. This works fine for rendering the first page, but the list disappears/is not correctly updated the second time around.

Example:

<?xml version="1.0" encoding="UTF-8"?>

<window xmlns:html="http://www.w3.org/1999/xhtml">
<listbox id="livelist" mold="paging" />
<zscript>
import org.zkoss.zul.*;
int pageSize = 4;
// prepare list cells
for (int i = 0; i < pageSize; i++) {
Listitem it = new Listitem();
it.appendChild(new Listcell());
livelist.appendChild(it);
}

p = livelist.getPaginal();
p.setTotalSize(30);
p.setPageSize(pageSize);
p.addEventListener("onPaging", new EventListener() {
public boolean isAsap() { return true; }
public void onEvent(Event e) {
int liveIndex = livelist.getVisibleBegin();
for (int listIndex = 0; listIndex < pageSize; listIndex++,
liveIndex++) {

livelist.getItems().get(listIndex).getChildren().get(0).setLabel("#" + liveIndex);
}
}
});
</zscript>
</window>


link publish delete flag offensive edit

answered 2007-06-16 14:22:44 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4365981

By: henrichen

What I suggest is using a separate Paging Component. In onPage() read the proper amount of data back. Then use these data to populate a default mold (NOT Paging mold)listbox, etc. The listbox will generate that many of listitems only since you only append that much of listitems.

Search "Paging" in Developer's Guide.

/henri

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: 2006-11-17 20:46:11 +0800

Seen: 300 times

Last updated: Jun 17 '07

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