0

listbox databinding paging 如何使用内置分页?

asked 2012-03-28 14:39:49 +0800

z155096552 gravatar image z155096552
42 1

<?page title="用户登录日志查询" contentType="text/html;charset=UTF-8"?>
<?variable-resolver class="org.zkoss.zkplus.spring.DelegatingVariableResolver"?>
<zk>
<window id="loginLogWin" title="用户登录日志查询" border="normal" apply="${loginLogListComposer}" width="100%">
<listbox id="loginLoglistbox" model="@{loginLogWin.loginLogList}">
<listhead>
<listheader label="登录名" align="center" draggable="true"/>
<listheader label="名称" align="center" draggable="true"/>
<listheader label="登录时间" align="center" draggable="true"/>
<listheader label="主机" align="center" draggable="true"/>
<listheader label="IP" align="center" draggable="true"/>
<listheader label="会话ID" align="center" draggable="true"/>
<listheader label="登录类型" align="center" draggable="true"/>
<listheader label="退出时间" align="center" draggable="true"/>
<listheader label="退出类型" align="center" draggable="true"/>
</listhead>
<listitem self="@{each=loginLog}">
<listcell label="@{loginLog.username}"></listcell>
<listcell label="@{loginLog.name}"></listcell>
<listcell label="@{loginLog.loginTime}"></listcell>
<listcell label="@{loginLog.serverHostname}"></listcell>
<listcell label="@{loginLog.clientIp}"></listcell>
<listcell label="@{loginLog.sessionId}"></listcell>
<listcell label="@{loginLog.loginType}"></listcell>
<listcell label="@{loginLog.quitTime}"></listcell>
<listcell label="@{loginLog.quitType}"></listcell>
</listitem>
<listfoot>
<listfooter span="9" width="100%">
<paging id="paging" pageSize="15" detailed="true" mold="os"></paging>
</listfooter>
</listfoot>
</listbox>
</window>
</zk>
如何使用内置的分页,不一次性查出数据,每次查pageSize的数据量
这是使用单独的Paging,工作一切正常
@Controller
@Scope("prototype")
public class LoginLogListComposer extends GenericForwardComposer {
@Autowired
private LoginLogService loginLogService;
Paging paging;
Listbox loginLoglistbox;
List<LoginLog> loginLogList = new ArrayList<LoginLog>();
LoginLog loginLog = new LoginLog();
private AnnotateDataBinder binder;
private static final long serialVersionUID = 5626357016778188646L;

public void doAfterCompose(Component comp) throws Exception {
super.doAfterCompose(comp);
comp.setAttribute("loginLogWin", this, true);
comp.setAttribute("loginLog", loginLog);
this.buildListbox(null);
binder = new AnnotateDataBinder(comp);
binder.bindBean("loginLoglistbox", loginLoglistbox);
binder.loadAll();
}

public void buildListbox(final LoginLogExample example) {
loginLoglistbox.setAutopaging(true);
loginLogList = loginLogService.selectByExample(example, paging.getActivePage()*paging.getPageSize(), paging.getPageSize());
paging.setTotalSize(loginLogService.countByExample(null));
paging.addEventListener("onPaging", new EventListener() {

public void onEvent(Event event) throws Exception {
loginLogList = loginLogService.selectByExample(example, paging.getActivePage()*paging.getPageSize(), paging.getPageSize());
binder.loadComponent(loginLoglistbox);
}
});
}
public List<LoginLog> getLoginLogList() {
return loginLogList;
}
public void setLoginLogList(List<LoginLog> loginLogList) {
this.loginLogList = loginLogList;
}
}

delete flag offensive retag edit

1 Reply

Sort by » oldest newest

answered 2012-05-21 09:33:20 +0800

paowang gravatar image paowang
140 6

可以參考這個範例: http://demo.zkoss.org/zkdemo/listbox/paging

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: 2012-03-28 14:39:49 +0800

Seen: 149 times

Last updated: May 21 '12

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