ZK - Open Source Ajax Java FrameworkZK - Open Source Ajax Java Framework

Not show the first page of paging component

fvargas
8 Sep 2010 10:43:10 GMT
8 Sep 2010 10:43:10 GMT

Hi,

I have a problem with the paging component and its first item.

I have this code in de .zul _file:

<paging id="custompaging" mold="os" totalSize="@{browserresults$composer.totalsize, load-after='browserresults.onSearch, browserresults.onRefreshContents'}" pageSize="1"/>
and a Listbox component declared previously.

In the java class controller I have this:

contentresults.setPaginal(custompaging);

custompaging.addEventListener("onPaging", new EventListener() {
public void onEvent(Event event) {
try {
refresh();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
});

The pagination works properly while I don´t press the First button, the Prev button or the 1 page button.

Any idea?

Thank you.

samchuang
8 Sep 2010 20:18:56 GMT
8 Sep 2010 20:18:56 GMT

Hi

I can't test your code, since the code is partial
I write a sample code, and it's working fine

zul

<?page title="new page title" contentType="text/html;charset=UTF-8"?>
<zk>
<window title="Custom Paging" border="normal" apply="demo.listbox.CustomPaging">
<zscript><![CDATA[
String[] ary = new String[10];
for (int i = 0; i < ary.length; i++) {
	ary<i > = "item " + i;
}
SimpleListModel model = new SimpleListModel(ary);
]]></zscript>
<paging id="paging" pageSize="1" totalSize="${model.size}"/>
<listbox id="listbox" model="${model}" mold="paging">
</listbox>

</window>
</zk>

java

/* CustomPaging.java

{{IS_NOTE
	Purpose:
		
	Description:
		
	History:
		Sep 9, 2010 8:51:04 AM , Created by Sam
}}IS_NOTE

Copyright (C) 2009 Potix Corporation. All Rights Reserved.

{{IS_RIGHT
	This program is distributed under GPL Version 3.0 in the hope that
	it will be useful, but WITHOUT ANY WARRANTY.
}}IS_RIGHT
*/
package demo.listbox;

import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.util.GenericForwardComposer;
import org.zkoss.zul.Listbox;
import org.zkoss.zul.Paging;

/**
 * @author Sam
 *
 */
public class CustomPaging extends GenericForwardComposer {

	Listbox listbox;
	Paging paging;
	@Override
	public void doAfterCompose(Component comp) throws Exception {
		super.doAfterCompose(comp);
		
		listbox.setPaginal(paging);
		paging.addEventListener("onPaging", new EventListener() {
			
			@Override
			public void onEvent(Event event) throws Exception {
				// TODO Auto-generated method stub
				//refresh();
				System.out.println("onPaging");
			}
		});
	}
	
}

I think you can try to get the totalSize see if that is correct or not

fvargas
9 Sep 2010 03:58:01 GMT
9 Sep 2010 03:58:01 GMT

Hi,

My Java class code is:

contentresults.setPaginal(custompaging);

custompaging.addEventListener("onPaging", new EventListener() {
public void onEvent(Event event) {
try {
refresh();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
});

the refresh function reloads the list with the items of the current page.

This is an example of load on demand.

In the .zul page I have the next code:

<listbox id="contentresults" fixedLayout="true" zclass="none" sclass="listadoMySites"
model="@{browserresults$composer.contentsvo, load-after='browserresults.onSearch'}">
<listhead>
<listheader align="center" style="width: 3em"/>
<listheader align="left" />
</listhead>
<listitem sclass="margeneslistitem" self="@{each='c'}">
<listcell style="vertical-align:middle">
<radio />
</listcell>

<listcell style="vertical-align:top">
<grid zclass="none">
<rows>
<row zclass="none">
<div>
<label value="${c:l('app.site')}: " sclass="negrita"/>
<a label="@{c.site.title}" />
</div>
</row>
<row zclass="none">
<label value="@{c.title}" sclass="negrita descripcion" />
</row>
<row zclass="none">
<div>
<label value="${c:l('app.contenttype')}: " sclass="negrita"/>
<label value="@{c.modeltype.title}" />
</div>
</row>
<row zclass="none">
<div>
<label value="${c:l('app.publishdate')}: " sclass="negrita"/>
<label value="@{c.modified}" />
</div>
</row>
</rows>
</grid>
</listcell>
</listitem>
</listbox>
<div sclass="alignRight">
<paging id="custompaging" mold="os" totalSize="@{browserresults$composer.totalsize, load-after='browserresults.onSearch, browserresults.onRefreshContents'}" pageSize="3"/>
</div>

The problem appears after the first load. In the first load everything is OK but if I press the other button and I try to go back to the first page, I can´t.

The list is for any element. You can use any example.

Thanks.

samchuang
9 Sep 2010 04:27:36 GMT
9 Sep 2010 04:27:36 GMT

Hi

I can't test your code, because you have other java object, browserresults and composer browserresults$composer and refresh() function code.

If possible, Could you post a runnable sample zul + java code, that can re-produce the problem ?