176142998

  BlogJava :: 首页 :: 联系 :: 聚合  :: 管理
  116 Posts :: 0 Stories :: 45 Comments :: 0 Trackbacks
转http://www.gzit.org/27/viewspace-3306.html

package com;

import java.util.ArrayList;关注ITz]'p6g5n-KlX
import java.util.List;

public class SimpleTest{关注IT1rq3XJw8K.uk&fK$w
 关注IT IQvF'S3U
 /**
ZyJ9l2@9@K0  *关注IT)~d3X(v*^ \jn3M
  * @return  所有公司
t8~)^.L.kq9Y0  */关注IT_ s9A?i:^Z
 public List<Company> getAllCompany(){
`Gq(c rzCG0  List<Company> list = new ArrayList<Company>();关注ITyc?n#P3H
  Company company = null;关注ITm n"o@a%vF#p8O
  company = new Company(1,"广西博联信息通信技术有限责任公司");关注IT7p9wloKHs
  list.add(company);
\t%? EgoZ/Jl3FI6r0  company = new Company(2,"能创信息科技有限责任公司");关注IT:kA E+Kh#UI
  list.add(company);
@"E}.U0t,V1I0  return list;关注IT9l#W*{"s&m
 }
!l0{"PF/z&y R9a.o/y0 
Ue3t N0^q%v.E0 /**
)^ D*FpTn+a5I!e0  *关注IT[1r^3g"Q,Ih
  * @param companyId  公司编号
-aWE)@QP&?}0  * @return  公司下所有部门
@4M,|PVgn!H L0  */关注IT0ZGrm:b'?
 public List<Department> getDepartment(int companyId){
W(o&TK Is0hC0  List<Department> list = new ArrayList<Department>();关注IT4V0v(t)v1J.TM,m.y
  Department department = null;
Wvc(d"g4D eV2A0  if(companyId==1){关注IT]$Z$X*W*mv8`%qQ
   department = new Department(1,1,"软件事业部");关注IT]!A F)AV\$I5J
   list.add(department);关注ITIYRRcSj
   department = new Department(2,1,"工程部");关注ITU rCpeq8M
   list.add(department);
5O#{ `8v8Ta)}B$L0  }else{关注IT ug,L?5[:y@k C:]
   department = new Department(1,2,"企管部");关注ITk/BY3iM/X,`%e
   list.add(department);关注IT&I7Z9{5`kV/l Avj |5L
   department = new Department(2,2,"财务部");
b'jm;yVa'Ww;Ea0   list.add(department);
z W Pp$yx3M0  }关注ITG gA3V5t0^ xM
  return list;
4O v#k$x:P3n0 }关注IT$tV5JN8sF u:FJ
 
y'b-^Bma0 /**关注IT/A(^g]jU P*u-\,H
  *关注IT:m'| NmVWtX/Y
  * @param departmentId  部门编号关注IT} l)^8GbA
  * @return   部门下所有员工关注IT.^VB |7V;b D'J'eH+n
  */
2gkge \x/ip-c4tW0 public List<Person> getPerson(int departmentId){关注ITFR*B5bnj_2[&Q
  List<Person> list = new ArrayList<Person>();
A@T5y8M]:H5h/c0  Person person = null;关注ITK Z-M ~MF
  if(departmentId==1){关注IT\t.T\3Mx
   person = new Person(1,1,"张三");关注ITe)_3a4xcw
   list.add(person);
wkw2P)G u7G(Z0   person = new Person(2,1,"李四");
{ uhJ;y9V&C` H0   list.add(person);
%q(xK1? VR0  }else{
s|] l)J:@o,p@y0   person = new Person(1,2,"王五");关注ITi'j*FST I
   list.add(person);关注IT^@j { x US i
   person = new Person(2,2,"赵六");关注IT ux#kse o;W
   list.add(person);
4B/cP*v5z [P0  }关注IT g Bc!D)p*jB)X
  return list;关注IT'X:[] lH
 }

}
d z-]6Gn/T9f1OR0

package com;

public class Company {

 private int id;关注IT|:NQQ,|8W,D!QV
 private String companyName;
$ffG s&X1|I0 关注ITy*eK ~4xog
 public Company(int id,String companyName){
.q;k2a&}j*LL0  this.id = id;
'\ u:Jpv)j0  this.companyName = companyName;关注ITV[,Ty8Fu
 }

 public int getId() {关注IT:F| |n-n!w$sX5PL
  return id;
NPPJ,?0 }

 public void setId(int id) {关注ITh2emjTe il+[D
  this.id = id;
W@b ` L4i0 }

 public String getCompanyName() {关注IT$wP8oO%} ?xe4k
  return companyName;
S0Kz%GX$?auN W0 }

 public void setCompanyName(String companyName) {
zMv*g ic8S&YqcN0  this.companyName = companyName;
v\'x-pT0 }

}
*mHu$CU~wb9x x0

package com;

public class Department {

 private int id;关注IT [n0zYU
 private int companyId;关注IT$S __L'FDvy2WD
 private String departmentName;

 public Department(int id, int companyId, String departmentName) {
,ni)o5G$yL'[o(}Q0  this.id = id;
q3Gzw"E6v8?o.MT0  this.companyId = companyId;关注IT+r"mo:pO$L![4U
  this.departmentName = departmentName;
/q\6Aj5]0m3G#l-P9a0 }

 public int getId() {
w"j`I` J0  return id;
x(P!d6tu v a"T0 }

 public void setId(int id) {关注ITlQ1r8wS5_'hb
  this.id = id;关注IT pGy3Jl{0tkW
 }

 public int getCompanyId() {
@!PpRi0  return companyId;关注ITs c!i"DQ5_D
 }

 public void setCompanyId(int companyId) {关注ITrp` i5D/_L
  this.companyId = companyId;关注ITYT+Y6CkJ t2x
 }

 public String getDepartmentName() {
fSa p.@9e&L0  return departmentName;关注IT!Pe L6m D7n wM
 }

 public void setDepartmentName(String departmentName) {关注IT/bD(o/RPq
  this.departmentName = departmentName;
'|S4q p4]0 }

}关注IT){0[0DsY:te9V A r$T

package com;

public class Person {

 private int id;
U{*D:dw+i6W0 private int departmentId;
q6a e ?5u5\ b|0?]KI0 private String userName;

 public Person(int id,int departmentId, String userName) {关注IT#c%qN s2Xup kIc
  this.id = id;关注ITs%z&uZ2T Bbj
  this.departmentId = departmentId;
|5nI&y.LO y)Cx(C.r b"x0  this.userName = userName;关注IT_,ep*n(H
 }

 public int getDepartmentId() {关注IT&ue1rG X%WJN[
  return departmentId;
"qn%DVY2mGh0 }

 public void setDepartmentId(int departmentId) {关注ITa? d(_7s
  this.departmentId = departmentId;关注IT+`vt Pb4oS
 }

 public String getUserName() {
]etq"Seza0  return userName;
3fZn} j-z(V+ir,a0 }

 public void setUserName(String userName) {
9pWKaR|0  this.userName = userName;
~FT_7a/l6lD$}V0 }

 public int getId() {
*i:k5KIZyr'o0  return id;
g+j[M(o`0 }

 public void setId(int id) {
vBj&P/` DUqB0  this.id = id;
:x:d5MOwo0 }

}
-KIsR)D9j7a+VDr rE3Ve0

<?xml version="1.0" encoding="UTF-8"?>关注ITWF0A~V
<!DOCTYPE dwr PUBLIC "-//GetAhead Limited//DTD Direct Web Remoting 1.0//EN" "dwr10.dtd" >关注IT GszT,f+Fc:RT
<dwr>
P/QC qq)cf0 <allow>关注IT.M%D9A4u{A&^`
  <!-- 声明哪个类可以提供JS直接调用 -->
Nf9r/PN%N-Du)D0  <create javascript="SimpleTest" creator="new">关注IT'T G m*[5A\#|1~;`%Y
   <param name="class" value="com.SimpleTest"></param>
\u)NR5z5QSP7t&@0   <!-- 该类里公开出来给JS调用的方法 -->
sh+c`K#sL'T#l0   <include method="getAllCompany" />关注IT$|i'^(lf$`y[2x I
   <include method="getDepartment" />
cP(^2LF5c:K$s*ce0   <include method="getPerson" />
_/J0?wiqL%w0  </create>
/zms8Vonw0  <!-- 类型转换 -->关注IT N*a#}ip*^H
  <convert match="com.Person" converter="bean">
.pV*p:QtOB0   <param name="include" value="id,departmentId,userName"></param>
5v8V6|3`U-WPya)nS0  </convert>
vu| ow4J b ^)@0  <convert match="com.Department" converter="bean">关注IT.g SgkS'u S]`
   <param name="include" value="id,companyId,departmentName"></param>关注ITX~_L nT
  </convert>
p3G!a/V;|y0  <convert match="com.Company" converter="bean">关注IT W6L q.dtp%Qv\
   <param name="include" value="id,companyName"></param>
z+sas-D)C"PS,|0  </convert>关注ITD/g|U2c:Y
 </allow>关注IT"['f&XZ`~
</dwr>关注IT,FruT'[ m%A1M

<%@ page language="java" pageEncoding="GB18030"%>关注IT*B&kW!{i
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
lgX^J G0<html>关注ITi'l*l#zG(q
  <head>   
uLA#O!~1s:c@0    <title>My JSP 'simpleTest.jsp' starting page</title>
eI-k1b-TDW w0   关注IT7g h.ICd(r
 <meta. http-equiv="pragma" content="no-cache">关注ITQ _-x5Mm
 <meta. http-equiv="cache-control" content="no-cache">关注ITe}yN |"S
 <meta. http-equiv="expires" content="0">   关注ITax(bO%Odh
 <meta. http-equiv="keywords" content="keyword1,keyword2,keyword3">
t%X$Wjx&VH.`0 <meta. http-equiv="description" content="This is my page">
/[Y7V5~PEWQ p0 
5b Z{3V!q O V5x1u!e0  </head>
)gD&OE\0  <script. type="text/javascript" src="dwr/engine.js"></script>关注IT1r"V3R{cP/~3Jc7Q
  <script. type="text/javascript" src="dwr/util.js"></script>关注IT#bM"@K,O@ X
  <script. type="text/javascript" src="dwr/interface/SimpleTest.js"></script>关注ITi(V6w \6~!l/a A#s [
 
6_*@k$wN0  <body nload="initial()">关注IT!nt9lT`1e/M%h
  <script. type="text/javascript">
y]#zLJE0  /*页面初始加载公司栏目*/关注IT?%]%wR7ICTg0_
  function initial(){
'h&BHt iEU0     SimpleTest.getAllCompany(function(data){dealSelect("i",data)});关注ITjty,Fwrb
  }关注IT&I!\_N d4xYHd
  /*获取下拉菜单的值并填充下一栏目*/
w)UR!qK$ma0  function show(flag){关注IT(y4Ff L4U5i
     if(flag=="c"){关注ITI$o+U{]r+k[Y
     var companyId = $("company").value;
_$|"Q7s)K-m"[/z*[)n0     SimpleTest.getDepartment(companyId,function(data){dealSelect(flag,data)});
cAj9K(u/g] E)I v6Iw0     }else if(flag=="d"){
J$L&o2}pD6kw0     var departmentId = $("department").value;
u}u'`\6~d*^0     SimpleTest.getPerson(departmentId,function(data){dealSelect(flag,data)});  
0@Vy ~cZF |0     } 
'X#Wc ?'| nW0  }关注ITk @#n[[&L&_OP5]4_o
  /*填充select的内容*/
NgcV,[0X0  function dealSelect(flag,data){
G YKF-I6HRfu)d0    clearSelect(flag);
1tC0BTVC?r3F0    if(flag=="c"){
*Td\#}%kT(|0    DWRUtil.addOptions("department",data,"id","departmentName");
9N#R2Pt4B0    }else if(flag=="d"){
Oj"@2V$l,{6L:K0    DWRUtil.addOptions("person",data,"id","userName");关注IT(I'Syg7[g[ l+R5r"l
    }else if(flag=="i"){
d'X'Fj5JJQ!Z8~0    DWRUtil.addOptions("company",data,"id","companyName");关注IT R W8[| x9a1QFq
    }
~m+hRysQ P T,c)?a0@0  }关注IT!e6B&wgK6a6W4f
  /*清除下拉表单的内容*/
6n`%~ j,_RU0  function clearSelect(flag){关注ITC1z#B-a6g3f/u*_
    if(flag=="c"){
I5c'e3n(|b0       var tmp = $("department");
)P$oa7G0AQ/o$cb0       while(tmp.childNodes.length>1){关注ITP(vJsB?XE"@
       tmp.removeChild(tmp.lastChild);
ew)j^q0       }
0H+J,D R8i0    }else if(flag="d"){关注ITl UJS P)e _-W
       var tmp = $("person");关注ITb-j-[&d&S }`[
       while(tmp.childNodes.length>1){
h8iOK4e0       tmp.removeChild(tmp.lastChild);
qTBv)hZ#v:X{+n0       }关注ITJZ,P0_C
    }关注IT`Tt5D({7P
  } 
y1ipi*J0  /*清空select里的内容*/
})uTT-t"Y0  </script>关注ITc ^2Wf ]p%g
    公司:<select id='company' nchange="show('c')"><option value="">======</option></select>关注ITLAD"Ei f8zo2uO
    部门:<select id='department' nchange="show('d')"><option value="">======</option></select>
z/VjF&{({0    成员:<select id='person'><option value="">======</option></select>
j!IJ$dQ0  </body>
;R$n'W7L){ n*^P IE.tr0</html>关注ITT[$[*l;x9I] N

posted on 2008-10-26 19:36 飞飞 阅读(556) 评论(0)  编辑  收藏 所属分类: dwr

只有注册用户登录后才能发表评论。


网站导航: