dwr级联特效

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">

		<title>级 联 特 效</title>
		<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
		<script type='text/javascript'
			src='/AjaxT7-SSHDwr/dwr/interface/deptService.js'></script>
		<script type='text/javascript'
			src='/AjaxT7-SSHDwr/dwr/interface/employeeService.js'></script>
		<script type='text/javascript' src='/AjaxT7-SSHDwr/dwr/engine.js'></script>
		<script type='text/javascript' src='/AjaxT7-SSHDwr/dwr/util.js'></script>
		<script type='text/javascript'>
	function getAllDepts() {
		deptService.getAllDepts(showDepts);
	}
	function showDepts(depts) {
		DWRUtil.removeAllOptions("deptId");
		DWRUtil.addOptions("deptId", depts);
	}
	function selectDept() {
		employeeService.getAllEmployeesByDeptId(DWRUtil.getValue("deptId"),
				showEmps);
	}
	function showEmps(emps) {
		DWRUtil.removeAllOptions("empId");
		DWRUtil.addOptions("empId", emps);
	}
</script>
	</head>

	<body οnlοad="getAllDepts()">
		<form name="myForm">
			部门:
			<select name="deptId" id="deptId" οnchange="javascript:selectDept();"></select>
			员工:
			<select name="empId" id="empId">
				<option>
					请选择部门
				</option>
			</select>
		</form>
	</body>
</html>

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE dwr PUBLIC "-//GetAhead Limited//DTD Direct Web Remoting 2.0//EN" "http://www.getahead.ltd.uk/dwr/dwr20.dtd">
<dwr>
	<allow>
		<create creator="spring" javascript="userService">
			<param name="beanName" value="userServiceBean" />
			<include method="login"></include>
			<include method="checkUserName"></include>
		</create>
		<create creator="spring" javascript="moduleService">
			<param name="beanName" value="moduleServiceBean" />
			<include method="getAllModules"></include>
		</create>
		<create creator="spring" javascript="deptService">
			<param name="beanName" value="deptServiceBean" />
			<include method="getAllDepts"></include>
		</create>
		<create creator="spring" javascript="employeeService">
			<param name="beanName" value="employeeServiceBean" />
			<include method="getAllEmployeesByDeptId"></include>
		</create>
		<convert match="com.tudou.ssh.entity.Employee" converter="bean"></convert>
		<convert match="com.tudou.ssh.entity.Dept" converter="bean"></convert>
		<convert match="com.tudou.ssh.entity.User" converter="bean"></convert>
		<convert match="com.tudou.ssh.entity.Module" converter="bean"></convert>
	</allow>
</dwr>


package com.tudou.ssh.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.tudou.ssh.dao.DeptDao;
import com.tudou.ssh.entity.Dept;
import com.tudou.ssh.util.BaseDao;

public class DeptService extends BaseDao implements DeptDao {

	@SuppressWarnings("unchecked")
	public Map<Integer, String> getAllDepts() {
		Map<Integer, String> depts=new HashMap<Integer, String>();
		List<Dept> depts2= this.getObjects();
		for(Dept d:depts2){
			depts.put(d.getDeptId(), d.getDeptName());
		}
		return depts;
	}

}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值