3. 人员信息展现的xsl文件(见addOrgPerson.xsl文件)
xsl文件同样是XML格式文件。所以一律遵守XML标准。下面对主要的行讲解:
<?xml version="1.0" encoding="gb2312"?>
//这是定义xml文件的首行。用来指明版本及字符集
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl" language="JavaScript">
//这里定义了stylesheet 元素。并指出其国际命名的组织及语言。
<xsl:template match="/">
<xsl:apply-templates select="peorsones"/>
</xsl:template>
//上面是匹配的规则。"/"表示从根结开始去匹配。匹配到下面的peorsones标记。这是正则表达式有关的学问。我们只要理解就可以。
<xsl:template match="peorsones">
//当匹配上peorsones时所要做的事情。
<table id="tbList" border="1" width="100%">
//定义一个id为"tbList的表格。此表格是显示在WEB上的
<xsl:for-each select="peorsone">
//循环匹配peorsone
<tr>
//定义tbList表格的一行,并在行上增加一个叫seqNo的属性名,值为匹配到的seqNo(序号)
<xsl:attribute name="seqNo"><xsl:value-of select="@seqNo"/></xsl:attribute>
<td>
//定义行上的一列,列又去匹配
<xsl:apply-templates select="."/>
</td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
<xsl:template match="peorsone">
<table border="1" width="100%">
<tr>
//定义宽为5%的一列,在该列上插入一个checkbox控件
<td width="5%">
<input type="checkbox" value="on" size="10"></input>
</td>
//定义一个不显示的列,在该列上插入一个text控件,text的值为匹配到的personId(人员Id)
<td style="display:none">
<input type="text" size="25">
<xsl:attribute name="value"><xsl:value-of select="personId"/></xsl:attribute>
</input>
</td>
<td width="30%">
<input type="text" size="20">
<xsl:attribute name="value"><xsl:value-of select="personCode"/></xsl:attribute>
</input>
</td>
<td width="40%">
<input type="text" size="40">
<xsl:attributename="value"><xsl:value-of select="personName"/></xsl:attribute>
</input>
</td>
//定义一个width为28%的列,在该列上插入一个下拉列表select 控件,select的值如果匹配到为0时则为"男",1时则为"女"
<td width="28%">
<select size="1">
<option value="0">
<xsl:if test=".[sex=0]">
<xsl:attribute name="selected">true</xsl:attribute>
</xsl:if>
男
</option>
<option value="1">
<xsl:if test=".[sex=1]">
<xsl:attribute name="selected">true</xsl:attribute>
</xsl:if>
女</option>
</select>
</td>
//定义一列,在该列上插入一个button控件,onclick 事件为自定义的方法,该方法传递当前单击的按纽
<td width="*">
<button onclick="openPersonRolePage(this)" style="width: 36; height: 21">角色</button>
</td>
</tr>
</table>
</xsl:template>
</xsl:stylesheet>
五、 数据接口的实现(见Org.jpg文件)
Org.JSP文件用来在服务器上运行Java的类与前台web页之间架起一座桥。取到中间件的接口作用。
这里分析部分代码:
<%@ page contentType="text/html; charset=GBK" %>
<%@ page import="java.sql.*" %>
<%@ page import="javax.naming.*" %>
<%@ page import="javax.sql.*" %>
<%@ page import="tool.*" %>
<%@ page import="orgNew.*" %>
<%@ page import="org.w3c.dom.*" %>
//上面主要是引用一些java类
<%
try{
//request.setCharacterEncoding("GBK");
Document doc = XmlTool.createDocumentFromRequest(request);
//建立web面文档请求的文档对象
Connection conn = ConnTool.getConnectionFromPool();
//获取请求的方法名
String mode=request.getParameter("mode");
//out.println("ccc");
//如果方法中没有其它参数则读取组织树数据
if(mode == null){
/* int OrgId = Integer.parseInt(request.getParameter("id"));
String str = orgManager.getChildOrg(OrgId, conn);
out.println(str);
*/
String str = orgManager.getTree(conn);
//out.println(str);
out.println(str);
}else if(mode.equals("createOrg")){
//如果是createOrg方法则建立一个组织
int parentOrgId = Integer.parseInt(request.getParameter("parentOrgId"));
//取出传递来的第一个参数parentOrgId
int OrgId = orgManager.createOrg(parentOrgId, conn);
//调用orgManager 类的createOrg方法来建立一个组织
out.println(OrgId);
//返回结果
}
conn.close();
}
catch(Exception e){
e.printStackTrace();
}
%>
上一页 [1] [2] [3] [4] [5] [6] [7] 下一页