jQuery treeview在JSP中的应用
2009-08-17 21:41
246 查看
1. 配置,其中jquery.js和jquery.cookie.js要用jquery-treeview/ lib/下的
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 = true;
}
return ret;
}
}
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 = true;
}
return ret;
}
}
相关文章推荐
- HTML,Jsp,Jquery 应用锚点实现页面的导航显示
- 4,jquery的ajax应用-jsp
- jquery.treeview.js树控件的应用
- 非常全的jquery treeview 应用
- jquery 在 jsp 中的应用
- 4,jquery的ajax应用-jsp
- jquery.treeview.js树控件的应用
- 当jsp文件放在某个文件夹下时jquery的$.ajax方法失效的--解决方案
- 整理一个ANT在J2EE项目中的应用,含预编译JSP和打包WAR/EAR文件!
- jsp使用jquery通过ajax方式访问servlet
- 【jquery仿dataList】应用之——模仿igoogle【定制化、拖动排序,最大化、分屏】
- .NET MVC Jquery EasyUI 联合应用示例
- jQuery实现Ajax应用加载(load/getJSON/getScript/get/post/serialize/ajax/ajaxSetup/ajaxStart/ajaxStop)
- 基于jQuery的Desktop【仿QQ WebOS 应用】
- (jsp和servlet功能篇)jsp+Jquery实现点击行,获取行数据
- 树形控件(MS TreeView 6.0 ActiveX Control)在网页中的应用
- 50多个强大的jQuery插件应用实例
- jQuery treeview在JSP中的应用:ASYNC
- asp.net MVC&JQuery 应用(表单验证)