1.html檔案
<html>
<head>
<link href="styles/wicket.css" target="_blank" rel="external nofollow" rel="stylesheet" type="text/css">
<link href="styles/office.css" target="_blank" rel="external nofollow" rel="stylesheet" type="text/css">
</head>
<body>
<h3>DataView+ListDataProvider例子</h3>
<form wicket:id ="form">
<span wicket:id ="navigator">這裡顯示分頁操作</span>
<table width="100%" cellspacing="1" cellpadding="0" id="baseCodeSetting">
<thead>
<tr>
<th align="center">姓名</th>
<th align="center" width="50">性别</th>
<th align="center">職務</th>
<th align="center">聯系電話</th>
<th align="center">QQ</th>
<th align="center">E-mail</th>
<th align="center">部落格位址</th>
<th align="center" width="50">操作</th>
</tr>
</thead>
<tbody>
<tr wicket:id="cards">
<td align="center" wicket:id ="name">title </td>
<td align="center" wicket:id ="sex">author</td>
<td align="center" wicket:id ="duty">duty</td>
<td align="center" wicket:id ="tel">tel</td>
<td align="center" wicket:id ="qq">qq</td>
<td align="center" wicket:id ="e_mail">e_mail</td>
<td align="center"><a wicket:id ="blog">blog</a></td>
<td align="center"><a wicket:id="edit">edit</a></td>
</tr>
</tbody>
</table >
</form>
</body>
</html>
2.java檔案
3.dao中的兩個方法
/**
* 根據Hql,傳回結果集中的一頁
* @param hql
* @param pageNo 第幾頁
* @param itemsPerPage 每頁記錄條數
* @return
*/
@SuppressWarnings("unchecked")
public List<T> findOnePageObjects(final String hql,final Integer pageNo,final Integer itemsPerPage){
return getHibernateTemplate().executeFind(new HibernateCallback() {
public Object doInHibernate(Session session) throws HibernateException, SQLException {
return session.createQuery(hql).setFirstResult(pageNo*itemsPerPage).setMaxResults(itemsPerPage).list();
}
});
}
/**
* 根據自己的制定的hql來查詢傳回的所有記錄的總數
*
* @param hql
* @return
*/
public int findRowCount(final String hql) {
return ((Long) getHibernateTemplate().execute(new HibernateCallback() {
public Object doInHibernate(Session session) throws HibernateException, SQLException {
return session.createQuery(hql).iterate().next();
}
})).intValue();
}