-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4018717
By: jim_pang
Hi..
I use ZK & Hibernate right now, it comes into problem when I want to retrieve
1000+ data. It runs very slow. I want to use Hibernate's paging and Zk's paging.
Does Zk already has any solution that incorporate Hibernate's paging? Such as..
I provide the codes that I want to retrieve, then ZK will define the maximum page, and will trigger the hibernate query everytime I move the pages.
Or other better solution.. ;)
thx.
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4020334
By: andigre
How do did you try?
I do it that way with 475 rows at the moment and it seems fast.
The ZUL page contains the grid with header only, the rows will be added dynamically.
<window xmlns="http://www.zkoss.org/2005/zul"
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"
id="winContent" sclass="contentx">
<separator spacing="10px"/>
<grid id="paginggrid" width="600px">
<columns>
<column label="Title"/>
<column label="Released"/>
<column label="Length"/>
<column label="Rating"/>
<column label="RC"/>
</columns>
</grid>
<separator spacing="25px"/>
</window>
Here is the code to add the content dynamically. It is important to set the Mold paging and the pageSize:
MovieUtil movieUtil = new MovieUtil();
Component cmp = movieUtil.getPageRows();
Grid grid = (Grid)getFellow("winContent").getFellow("paginggrid");
grid.appendChild(cmp);
grid.setMold("paging");
grid.setPageSize(Constants.PAGE_SIZE);
grid.applyProperties();
And my util function to build the rows:
public Component getPageRows() {
Rows rows = new Rows();
MovieDAO mDAO = new MovieDAO();
List lst = mDAO.getAllMovies();
for (Object aLst : lst) {
Movie movie = (Movie) aLst;
Row row = new Row();
Label label1 = new Label();
Label label2 = new Label();
Label label3 = new Label();
Label label4 = new Label();
Label label5 = new Label();
label1.setValue(movie.getTitle());
label1.setTooltip("details");
label1.setId("mv_" + movie.getId());
label2.setValue("" + movie.getReleased());
label3.setValue("" + movie.getLength());
label4.setValue(movie.getFsk());
label5.setValue("" + movie.getRegion());
row.appendChild(label1);
row.appendChild(label2);
row.appendChild(label3);
row.appendChild(label4);
row.appendChild(label5);
rows.appendChild(row);
}
return rows;
}
and the DAO to fetch the data:
public List getAllMovies() throws DatabaseException {
try
{
Criteria c = getSession().createCriteria(Movie.class);
c.addOrder(Order.asc("title"));
return c.list();
}
catch (HibernateException hibernateException)
{
throw new DatabaseException("Could not get the moviePage. ", hibernateException);
}
}
Hope this helps.
/Andreas
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4020537
By: jim_pang
Same as u do Andreas. But it is wiser if you use Hibernate paging, since it would take only the data you need. Retrieving 1000+ data or more, 10k+ (maybe)data would cause traffic jam. And it is the scenario that we try to avoid right?
So, I'm still curious, if ZK has capabilities to link up with Hibernate paging.
So everytimes we move page, it would re-query. Maybe we should only pass the query, max result, and max page, ZK handle the current page state.
thx..
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4020581
By: henrichen
You can write a "smart" list model that would do the trick you mentioned.
OR
You can write an "onPaging" event handler that would do the trick you mentioned.
/henri
Asked: 2006-11-18 02:51:43 +0800
Seen: 441 times
Last updated: Nov 20 '06