2. navigation.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="css/jquery.treeview.css" />
<link rel="stylesheet" href="css/screen.css" />
<script src="javascript/jquery.js" type="text/javascript"></script>
<script src="javascript/jquery.cookie.js" type="text/javascript"></script>
<script src="javascript/jquery.treeview.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#navigation").treeview({
control: "#treecontrol",
persist: "location",
collapsed: true
});
});
</script>
</head>
<body>
<h1 id="banner">
<a
href="http://bassistance.de/jquery-plugins/jquery-plugin-treeview/">jQuery
Treeview Plugin</a> Demo
</h1>
<div id="main">
<a href=".">Main</a>
<h4>
Sample - navigation
</h4>
<div id="treecontrol">
<a title="Collapse the entire tree below" href="#"><img
src="images/minus.gif" /> Collapse All</a>
<a title="Expand the entire tree below" href="#"><img
src="images/plus.gif" /> Expand All</a>
<a
title="Toggle the tree below, opening closed branches, closing open branches"
href="#">Toggle All</a>
</div>
<ul id="navigation">
<c:forEach var="list" items="${list}">
<li>
${list.item}
<c:if test="${empty list.itemsForItemId == false}">
<ul>
<c:forEach var="list1" items="${list.itemsForItemId}">
<li>
${list1.item}
</li>
</c:forEach>
</ul>
</c:if>
</li>
</c:forEach>
</ul>
</div>
</body>
</html>
3. TestController
@Controller
public class TestController {
@Autowired
TestDao testDao;
@RequestMapping("/navigation.html")
public String navigation(HttpServletRequest request) {
request.setAttribute("list", testDao.findTopItem());
return "navigation";
}
@RequestMapping("/async.html")
public String async(HttpServletRequest request) {
return "async";
}
}
4. TestDaoImpl
@Repository("testDao")
public class TestDaoImpl extends HibernateBaseDao implements TestDao {
@SuppressWarnings("unchecked")
public List<Item> findTopItem() {
return getHibernateTemplate().find("from Item where itemLevel = 1");
}
@SuppressWarnings("unchecked")
public List<Item> find(Long itemId) {
return getHibernateTemplate().find("from Item a where a.itemId = ?",
itemId);
}
@SuppressWarnings("unchecked")
public List<Item> findSubItem(Long itemId) {
List<Item> list = new ArrayList();
List<Item> itemList = find(itemId);
Set<Item> subList = itemList.get(0).getItemsForItemId();
for (Item item2 : subList) {
list.add(item2);
}
return list;
}
public Boolean hasSubItem(Long itemId) {
Boolean ret = false;
List<Item> subList = findSubItem(itemId);
if (!subList.isEmpty()) {
ret = lang