- 浏览: 172423 次
- 性别:
- 来自: 成都
文章分类
最新评论
-
gwill_21:
dwr.xml找不到怎么办,难道要自己手写dwr.xml?痛苦 ...
DWR框架 —— 用户注册验证 -
recoba7:
MLDN魔乐科技 Oracle学习笔记 (5) -
lanni2460:
呵呵 尽管现在才看到这个 但是我真的觉得 李老师 讲的很好呢 ...
严重声明,那些恶意诋毁MLDN及李兴华老师的其他培训机构统统走开 -
chian_xxp:
只要把功能实现了,代码结构合理了,代码性能提高了,该注意的注意 ...
业务、业务、业务。。。 -
wzpbb:
密码多少啊??? 给一下啊
MLDN 魔乐科技 Oracle 学习笔记(2)
今天讲解的ecside组件,这个组件听李老师介绍说是有了些改进,不过作为这些组件我觉得搞的头还是挺大的,但其实代码不多,只是需要根据一些文档进行调试就行了,我感觉这些东西整体来讲跟之前学习的并没有多大的不同。
今天所讲的知识点
A ECSide概述
B ECSide实现列表功能
我对知识点的分析
A ECSide概述
在EC框架基础上出现的,EC是Java SE 的框架,用来完成Swing界面,ECSide在EC 框架的基础上,取出其中比较有用的一些核心代码,完成ECSide框架。
ECSide是Java EE的框架,使用了AJAX技术,完成信息的显示,及添加修改删除等功能,并可以支持数据导出。
ExtJS也是EC框架发展出来的,可以在页面上完成所有EC之前的功能,但现在已经开始收费。
B ECSide实现列表功能
一、建立数据库
sql脚本
/*==============================================================*/
/* DBMS name: MySQL 5.0 */
/* Created on: 2009-5-13 16:04:15 */
/*==============================================================*/
drop database ecside;
create database ecside;
use ecside;
drop table if exists employee;
drop table if exists role;
/*==============================================================*/
/* Table: employee */
/*==============================================================*/
create table employee
(
username varchar(30) not null,
password varchar(32) not null,
name varchar(30) not null,
tel varchar(20) not null,
roleid int not null,
rolename varchar(50) not null,
status int not null,
isLock int not null,
primary key (username)
);
/*==============================================================*/
/* Table: role */
/*==============================================================*/
create table role
(
id int not null auto_increment,
name varchar(50) not null,
description text not null,
primary key (id)
);
insert into role (name,description) values('系统管理员','最高权限用户,系统的超级用户。不参与具体的技术服务');
insert into role (name,description) values('业务员','公司业务接收、跟踪人员,可分配任务给技术主管及技术员。不参与具体的技术服务');
insert into role (name,description) values('技术主管','负责管理技术人员,可分配具体任务给技术人员,在任务较多的情况下,也可以当成一个技术人员负责具体任务的服务');
insert into role (name,description) values('技术员','公司技术服务人员,负责具体任务的服务工作,如安装操作系统,维修硬件设备');
insert into employee values('admin','21232F297A57A5A743894A0E4A801FC3','张三','13661234567',1,'系统管理员',1,1);
insert into employee values('testaa','21232F297A57A5A743894A0E4A801FC3','李四','13661234567',2,'业务员',1,1);
insert into employee values('testbb','21232F297A57A5A743894A0E4A801FC3','王五','13661234567',3,'技术主管',1,1);
insert into employee values('testcc','21232F297A57A5A743894A0E4A801FC3','小六','13661234567',4,'技术员',1,1);
二、建立项目并加入相应的支持
(1)引入Struts支持(并非必须,只是现在刚刚学习了Struts)
(2) 为项目加入ECSide支持
(3)加入支持jar包,将所有jar包和字体支持文件拷贝到项目的lib下;
加入ECSide的标签库,将标签拷贝到项目的WEB-INF下;
加入ECSide的css样式及js支持等内容,将common与ecside文件夹拷贝到项目的WebRoot下;
在web.xml中加入 ECSide的过滤器;
<filter>
<filter-name>ecsideExport</filter-name>
<filter-class>org.ecside.filter.ECSideFilter</filter-class>
<init-param>
<param-name>useEasyDataAccess</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>useEncoding</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>encoding</param-name>
<param-value>GBK</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>ecsideExport</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
三、编写后台DAO代码
vo—dbc—dao—dao_impl—dao_proxy—factory
vo
package mldn.lin.vo;
public class Employee {
private String username; //雇员的用户名,用于登陆系统用
private String password; //密码,MD5Code方式加密
private String name; //雇员真实姓名
private String tel; //雇员联系电话
private int roleid; //角色编号
private String rolename; //角色名称(冗余字段)
private int status; //雇员休假状态
private int isLock; //用户名锁定状态
public int getIsLock() {
return isLock;
}
public void setIsLock(int isLock) {
this.isLock = isLock;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getRoleid() {
return roleid;
}
public void setRoleid(int roleid) {
this.roleid = roleid;
}
public String getRolename() {
return rolename;
}
public void setRolename(String rolename) {
this.rolename = rolename;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public String getTel() {
return tel;
}
public void setTel(String tel) {
this.tel = tel;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
}
dbc
package mldn.lin.dbc;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
//mysql
public class DataBaseConnectionJDBC {
private static final String DBDRIVER="org.gjt.mm.mysql.Driver";
private static final String DBURL="jdbc:mysql://localhost:3306/ecside";
private static final String DBUSER="root";
private static final String DBPASSWORD="mysqladmin";
private Connection conn=null;
public DataBaseConnectionJDBC() {
super();
try {
Class.forName(DBDRIVER);
this.conn=DriverManager.getConnection(DBURL, DBUSER, DBPASSWORD);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}catch (SQLException e) {
e.printStackTrace();
}
}
//定义取得数据库连接的方法
public Connection getConnection(){
try {
if(this.conn==null || this.conn.isClosed()){
Class.forName(DBDRIVER);
conn=DriverManager.getConnection(DBURL, DBUSER, DBPASSWORD);
}
} catch (SQLException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
return conn;
}
//定义关闭数据库连接的方法
public void close(){
if(this.conn!=null){
try {
this.conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}
dao
package mldn.lin.dao;
import java.util.List;
import java.util.Map;
import mldn.lin.vo.Employee;
public interface IEmployeeDAO {
/**
* 添加记录的方法
* @param all 所有要添加的记录
* @return 是否插入成功
* @throws Exception
*/
public boolean doInsert(List<Employee> all)throws Exception;
/**
* 删除记录的方法
* @param ids 所有要删除的记录的主键值
* @return 是否删除成功
* @throws Exception
*/
public boolean doDelete(String[] usernames)throws Exception;
/**
* 更新记录的方法
* @param all 所有修改后的记录
* @return 是否修改成功
* @throws Exception
*/
public boolean doUpdate(List<Employee> all)throws Exception;
/**
* 查询全部记录的方法
* @param startRow 开始的记录数(索引)
* @param endRow 结束的记录(索引)
* @param searchMap 所有查询条件,key为字段名称,value为所要查询的关键字
* @param sortMap 所有排序条件,key为排序的字段名称,value为排序规则(升序、降序)
* @return 所有查询结果
* @throws Exception
*/
public List<Employee> doSelectAll(int startRow,int endRow,Map searchMap,Map sortMap)throws Exception;
/**
* 查询全部记录数
* @param searchMap 所有查询条件,key为字段名称,value为所要查询的关键字
* @return 返回符合条件的记录数,没有返回0
* @throws Exception
*/
public int getAllCount(Map searchMap)throws Exception;
}
dao_impl
package mldn.lin.impl;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import mldn.lin.dao.IEmployeeDAO;
import mldn.lin.dbc.DataBaseConnectionJDBC;
import mldn.lin.vo.Employee;
import org.ecside.util.ECSideUtils;
public class EmployeeDAOImpl implements IEmployeeDAO {
private DataBaseConnectionJDBC dbc;
public EmployeeDAOImpl (DataBaseConnectionJDBC dbc){
this.dbc=dbc;
}
public boolean doInsert(List<Employee> all) throws Exception {
// TODO Auto-generated method stub
String sql="INSERT INTO employee (username,password,name,tel,roleid,rolename,status,isLock) VALUES(?,?,?,?,?,?,?,?)";
PreparedStatement prmt=this.dbc.getConnection().prepareStatement(sql);
Iterator iter=all.iterator();
Employee emp=new Employee();
while(iter.hasNext()){
emp=(Employee) iter.next();
prmt.setString(1, emp.getUsername());
prmt.setString(2, emp.getPassword());
prmt.setString(3, emp.getName());
prmt.setString(4, emp.getTel());
prmt.setInt(5, emp.getRoleid());
prmt.setString(6, emp.getRolename());
prmt.setInt(7, emp.getStatus());
prmt.setInt(8, emp.getIsLock());
if(prmt.executeUpdate()==0){
return false;
}
}
return true;
}
public boolean doDelete(String[] usernames) throws Exception {
// TODO Auto-generated method stub
String sql="DELETE FROM employee WHERE username IN(";
for(int i=0;i<usernames.length;i++){
if(i<usernames.length-1){
sql+="?,";
}else{
sql+="?)";
}
}
PreparedStatement prmt=this.dbc.getConnection().prepareStatement(sql);
for(int i=0;i<usernames.length;i++){
prmt.setString(i+1, usernames[i]);
}
if(prmt.executeUpdate()>=0){
return true;
}
return false;
}
public boolean doUpdate(List<Employee> all) throws Exception {
// TODO Auto-generated method stub
String sql="UPDATE employee SET password=?,name=?,tel=?,roleid=?,rolename=?,status=?,isLock=? WHERE username=?";
PreparedStatement prmt=this.dbc.getConnection().prepareStatement(sql);
Iterator iter=all.iterator();
Employee emp=new Employee();
while(iter.hasNext()){
emp=(Employee) iter.next();
prmt.setString(1, emp.getPassword());
prmt.setString(2, emp.getName());
prmt.setString(3, emp.getTel());
prmt.setInt(4, emp.getRoleid());
prmt.setString(5, emp.getRolename());
prmt.setInt(6, emp.getStatus());
prmt.setInt(7, emp.getIsLock());
prmt.setString(8, emp.getUsername());
if(prmt.executeUpdate()==0){
return false;
}
}
return true;
}
public List<Employee> doSelectAll(int startRow, int endRow, Map searchMap,
Map sortMap) throws Exception {
// TODO Auto-generated method stub
String sql="SELECT username,password,name,tel,roleid,rolename,status,isLock FROM employee WHERE 1=1";
if(searchMap!=null){
Iterator iter=searchMap.entrySet().iterator();
if(iter.hasNext()){
sql+=" AND ";
Map.Entry entry=(Entry) iter.next();
if(entry.getKey().equals("roleid") || entry.getKey().equals("status") || entry.getKey().equals("isLock")){
sql+=entry.getKey()+"="+entry.getValue();
}else{
sql+=entry.getKey()+" LIKE '%"+entry.getValue()+"%'";
}
}
}
if(sortMap!=null){
sql+=" "+ ECSideUtils.getDefaultSortSQL(sortMap);
}
sql+=" LIMIT ?,?";
PreparedStatement prmt=this.dbc.getConnection().prepareStatement(sql);
prmt.setInt(1, startRow);
prmt.setInt(2, (endRow-startRow));
ResultSet rs=prmt.executeQuery();
List<Employee> all=null;
while(rs.next()){
if(all==null){
all=new ArrayList<Employee>();
}
Employee emp=new Employee();
emp.setUsername(rs.getString(1));
emp.setPassword(rs.getString(2));
emp.setName(rs.getString(3));
emp.setTel(rs.getString(4));
emp.setRoleid(rs.getInt(5));
emp.setRolename(rs.getString(6));
emp.setStatus(rs.getInt(7));
emp.setIsLock(rs.getInt(8));
all.add(emp);
}
return all;
}
public int getAllCount(Map searchMap) throws Exception {
// TODO Auto-generated method stub
String sql="SELECT count(*) FROM employee WHERE 1=1";
if(searchMap!=null){
Iterator iter=searchMap.entrySet().iterator();
if(iter.hasNext()){
sql+=" AND ";
Map.Entry entry=(Entry) iter.next();
if(entry.getKey().equals("roleid") || entry.getKey().equals("status") || entry.getKey().equals("isLock")){
sql+=entry.getKey()+"="+entry.getValue();
}else{
sql+=entry.getKey()+" LIKE '%"+entry.getValue()+"%'";
}
}
}
PreparedStatement prmt=this.dbc.getConnection().prepareStatement(sql);
ResultSet rs=prmt.executeQuery();
int count=0;
if(rs.next()){
count=rs.getInt(1);
}
return count;
}
}
dao_proxy
package mldn.lin.proxy;
import java.sql.PreparedStatement;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import mldn.lin.dao.IEmployeeDAO;
import mldn.lin.dbc.DataBaseConnectionJDBC;
import mldn.lin.impl.EmployeeDAOImpl;
import mldn.lin.vo.Employee;
public class EmployeeDAOProxy implements IEmployeeDAO {
private DataBaseConnectionJDBC dbc;
private IEmployeeDAO iemployeedao;
public EmployeeDAOProxy (){
this.dbc=new DataBaseConnectionJDBC();
this.iemployeedao=new EmployeeDAOImpl(this.dbc);
}
public boolean doInsert(List<Employee> all) throws Exception {
// TODO Auto-generated method stub
if(all==null){
return false;
}
this.dbc.getConnection().setAutoCommit(false);
boolean flag=false;
try {
flag=this.iemployeedao.doInsert(all);
if(flag){
this.dbc.getConnection().commit();
}else{
this.dbc.getConnection().rollback();
}
} catch (RuntimeException e) {
this.dbc.getConnection().rollback();
e.printStackTrace();
}finally{
this.dbc.close();
}
return true;
}
public boolean doDelete(String[] usernames) throws Exception {
// TODO Auto-generated method stub
if(usernames==null){
return false;
}
boolean flag=false;
try {
flag=this.iemployeedao.doDelete(usernames);
} catch (RuntimeException e) {
e.printStackTrace();
}finally{
this.dbc.close();
}
return flag;
}
public boolean doUpdate(List<Employee> all) throws Exception {
// TODO Auto-generated method stub
if(all==null){
return false;
}
this.dbc.getConnection().setAutoCommit(false);
boolean flag=false;
try {
flag=this.iemployeedao.doUpdate(all);
if(flag){
this.dbc.getConnection().commit();
}else{
this.dbc.getConnection().rollback();
}
} catch (RuntimeException e) {
this.dbc.getConnection().rollback();
e.printStackTrace();
}finally{
this.dbc.close();
}
return true;
}
public List<Employee> doSelectAll(int startRow, int endRow, Map searchMap,
Map sortMap) throws Exception {
// TODO Auto-generated method stub
List all=null;
try {
all=this.iemployeedao.doSelectAll(startRow, endRow, searchMap, sortMap);
} catch (RuntimeException e) {
e.printStackTrace();
}finally{
this.dbc.close();
}
return all;
}
public int getAllCount(Map searchMap) throws Exception {
// TODO Auto-generated method stub
int count=0;
try {
count=this.iemployeedao.getAllCount(searchMap);
} catch (RuntimeException e) {
e.printStackTrace();
}finally{
this.dbc.close();
}
return count;
}
}
factory
package mldn.lin.dao.factory;
import mldn.lin.dao.IEmployeeDAO;
import mldn.lin.dao.IRoleDAO;
import mldn.lin.proxy.EmployeeDAOProxy;
import mldn.lin.proxy.RoleDAOProxy;
public class DAOFactory {
public static IEmployeeDAO getIEmployeeDAOInstance(){
return new EmployeeDAOProxy();
}
}
四、建立超链接列表页
<%@ page language="java" pageEncoding="GBK"%>
<%
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>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<center>
<a href="employee.do?status=list">进入列表</a>
</center>
</body>
</html>
五、建立Action与ActionForm
ActionForm
/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package mldn.lin.struts.form;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
/**
* MyEclipse Struts
* Creation date: 05-13-2009
*
* XDoclet definition:
* @struts.form name="employForm"
*/
public class EmployForm extends ActionForm {
/*
* Generated fields
*/
/** status property */
private String status;
/*
* Generated Methods
*/
/**
* Method validate
* @param mapping
* @param request
* @return ActionErrors
*/
public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {
// TODO Auto-generated method stub
return null;
}
/**
* Method reset
* @param mapping
* @param request
*/
public void reset(ActionMapping mapping, HttpServletRequest request) {
// TODO Auto-generated method stub
}
/**
* Returns the status.
* @return String
*/
public String getStatus() {
return status;
}
/**
* Set the status.
* @param status The status to set
*/
public void setStatus(String status) {
this.status = status;
}
}
Action
/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package mldn.lin.struts.action;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import mldn.lin.dao.factory.DAOFactory;
import mldn.lin.struts.form.EmployForm;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;
import org.ecside.table.limit.Limit;
import org.ecside.util.RequestUtils;
/**
* MyEclipse Struts
* Creation date: 05-13-2009
*
* XDoclet definition:
* @struts.action path="/employ" name="employForm" input="/error.jsp" parameter="status" scope="request" validate="true"
*/
public class EmployAction extends DispatchAction {
/*
* Generated Methods
*/
/**
* Method execute
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
public ActionForward list(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
EmployForm employForm = (EmployForm) form;// TODO Auto-generated method stub
Limit limit=RequestUtils.getLimit(request);
Map searchMap=limit.getFilterSet().getPropertyValueMap();
Map sortMap=limit.getSort().getSortValueMap();
try {
int allRecorders = DAOFactory.getIEmployeeDAOInstance().getAllCount(searchMap);
int[] startEndRow=RequestUtils.getRowStartEnd(request, allRecorders, 5);
List all=DAOFactory.getIEmployeeDAOInstance().doSelectAll(startEndRow[0], startEndRow[1], searchMap, sortMap);
request.setAttribute("allEmployee", all);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return mapping.findForward("list");
}
}
web.xml
<?xml version="1.0" encoding="GBK"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>3</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>3</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<filter>
<filter-name>ecsideExport</filter-name>
<filter-class>org.ecside.filter.ECSideFilter</filter-class>
<init-param>
<param-name>useEasyDataAccess</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>useEncoding</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>encoding</param-name>
<param-value>GBK</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>ecsideExport</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
struts_config.xml
<?xml version="1.0" encoding="GBK"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd">
<struts-config>
<data-sources />
<form-beans >
<form-bean name="employForm" type="mldn.lin.struts.form.EmployForm" />
</form-beans>
<global-exceptions />
<global-forwards />
<action-mappings >
<action
attribute="employForm"
input="/error.jsp"
name="employForm"
parameter="status"
path="/employee"
scope="request"
type="mldn.lin.struts.action.EmployAction" >
<forward name="list" path="/list.jsp"></forward>
</action>
</action-mappings>
<message-resources parameter="mldn.lin.struts.ApplicationResources" />
</struts-config>
六、在列表页上导入ECSide的标签、支持js、样式表
<%@ page language="java" pageEncoding="GBK"%>
<%@ taglib uri="http://www.ecside.org" prefix="ec"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html:html lang="true">
<head>
<html:base />
<title>list.jsp</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<script type="text/javascript"
src="${pageContext.request.contextPath }/ecside/js/ecside_msg_gbk_cn.js"></script>
<script type="text/javascript"
src="${pageContext.request.contextPath }/ecside/js/prototype_mini.js"></script>
<script type="text/javascript"
src="${pageContext.request.contextPath }/ecside/js/ecside.js"></script>
<link rel="stylesheet" type="text/css"
href="${pageContext.request.contextPath }/ecside/css/ecside_style.css">
</head>
七、列表显示数据
<center>
<ec:table width="800" items="allEmployee" var="employee"
retrieveRowsCallback="limit" sortRowsCallback="limit"
filterRowsCallback="limit" action="employee.do?status=list"
useAjax="true" pageSizeList="2,5,10,50,all" rowsDisplayed="5"
title="" editable="true" xlsFileName="文件1.xls" csvFileName="文件2.csv"
pdfFileName="文件3.pdf" showPrint="true" sortable="true"
resizeColWidth="true" filterable="true"
updateAction="employee.do?status=update"
insertAction="employee.do?status=insert"
deleteAction="employee.do?status=delete" classic="true">
<ec:row recordKey="${employee.username}">
<ec:column property="username" title="用户名"></ec:column>
<ec:column property="password" title="密码"></ec:column>
<ec:column property="name" title="真实姓名"></ec:column>
<ec:column property="tel" title="联系方式"></ec:column>
<ec:column property="rolename" title="权限"></ec:column>
<ec:column property="status" title="是否休假"></ec:column>
<ec:column property="isLock" title="是否锁定"></ec:column>
</ec:row>
</ec:table>
</center>
八、实现查询功能
<center>
<ec:table width="800" items="allEmployee" var="employee"
retrieveRowsCallback="limit" sortRowsCallback="limit"
filterRowsCallback="limit" action="employee.do?status=list"
useAjax="true" pageSizeList="2,5,10,50,all" rowsDisplayed="5"
title="" editable="true" xlsFileName="文件1.xls" csvFileName="文件2.csv"
pdfFileName="文件3.pdf" showPrint="true" sortable="true"
resizeColWidth="true" filterable="true"
updateAction="employee.do?status=update"
insertAction="employee.do?status=insert"
deleteAction="employee.do?status=delete" classic="true">
<ec:row recordKey="${employee.username}">
<ec:column property="username" title="用户名"></ec:column>
<ec:column property="password" title="密码"></ec:column>
<ec:column property="name" title="真实姓名"></ec:column>
<ec:column property="tel" title="联系方式"></ec:column>
<ec:column property="rolename" title="权限"></ec:column>
<ec:column property="status" title="是否休假"></ec:column>
<ec:column property="isLock" title="是否锁定"></ec:column>
</ec:row>
</ec:table>
<!-- 编辑和过滤所使用的 通用的文本框模板 -->
<textarea id="ecs_t_date" rows="" cols="" style="display: none">
<input type="text" class="inputtext" value="" style="width: 100px;" name="" />
<input class="calendarImgButton" onclick="ECSideUtil.showCalendar(this)" type="button" id="date_button" />
</textarea>
<!-- 编辑和过滤所使用的 通用的文本框模板 -->
<textarea id="ecs_t_input" rows="" cols="" style="display: none">
<input type="text" class="inputtext" value="" onblur="ECSideUtil.updateEditCell(this)" style="width: 100%;" name="" />
</textarea>
</center>
今天所讲的知识点
A ECSide概述
B ECSide实现列表功能
我对知识点的分析
A ECSide概述
在EC框架基础上出现的,EC是Java SE 的框架,用来完成Swing界面,ECSide在EC 框架的基础上,取出其中比较有用的一些核心代码,完成ECSide框架。
ECSide是Java EE的框架,使用了AJAX技术,完成信息的显示,及添加修改删除等功能,并可以支持数据导出。
ExtJS也是EC框架发展出来的,可以在页面上完成所有EC之前的功能,但现在已经开始收费。
B ECSide实现列表功能
一、建立数据库
sql脚本
/*==============================================================*/
/* DBMS name: MySQL 5.0 */
/* Created on: 2009-5-13 16:04:15 */
/*==============================================================*/
drop database ecside;
create database ecside;
use ecside;
drop table if exists employee;
drop table if exists role;
/*==============================================================*/
/* Table: employee */
/*==============================================================*/
create table employee
(
username varchar(30) not null,
password varchar(32) not null,
name varchar(30) not null,
tel varchar(20) not null,
roleid int not null,
rolename varchar(50) not null,
status int not null,
isLock int not null,
primary key (username)
);
/*==============================================================*/
/* Table: role */
/*==============================================================*/
create table role
(
id int not null auto_increment,
name varchar(50) not null,
description text not null,
primary key (id)
);
insert into role (name,description) values('系统管理员','最高权限用户,系统的超级用户。不参与具体的技术服务');
insert into role (name,description) values('业务员','公司业务接收、跟踪人员,可分配任务给技术主管及技术员。不参与具体的技术服务');
insert into role (name,description) values('技术主管','负责管理技术人员,可分配具体任务给技术人员,在任务较多的情况下,也可以当成一个技术人员负责具体任务的服务');
insert into role (name,description) values('技术员','公司技术服务人员,负责具体任务的服务工作,如安装操作系统,维修硬件设备');
insert into employee values('admin','21232F297A57A5A743894A0E4A801FC3','张三','13661234567',1,'系统管理员',1,1);
insert into employee values('testaa','21232F297A57A5A743894A0E4A801FC3','李四','13661234567',2,'业务员',1,1);
insert into employee values('testbb','21232F297A57A5A743894A0E4A801FC3','王五','13661234567',3,'技术主管',1,1);
insert into employee values('testcc','21232F297A57A5A743894A0E4A801FC3','小六','13661234567',4,'技术员',1,1);
二、建立项目并加入相应的支持
(1)引入Struts支持(并非必须,只是现在刚刚学习了Struts)
(2) 为项目加入ECSide支持
(3)加入支持jar包,将所有jar包和字体支持文件拷贝到项目的lib下;
加入ECSide的标签库,将标签拷贝到项目的WEB-INF下;
加入ECSide的css样式及js支持等内容,将common与ecside文件夹拷贝到项目的WebRoot下;
在web.xml中加入 ECSide的过滤器;
<filter>
<filter-name>ecsideExport</filter-name>
<filter-class>org.ecside.filter.ECSideFilter</filter-class>
<init-param>
<param-name>useEasyDataAccess</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>useEncoding</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>encoding</param-name>
<param-value>GBK</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>ecsideExport</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
三、编写后台DAO代码
vo—dbc—dao—dao_impl—dao_proxy—factory
vo
package mldn.lin.vo;
public class Employee {
private String username; //雇员的用户名,用于登陆系统用
private String password; //密码,MD5Code方式加密
private String name; //雇员真实姓名
private String tel; //雇员联系电话
private int roleid; //角色编号
private String rolename; //角色名称(冗余字段)
private int status; //雇员休假状态
private int isLock; //用户名锁定状态
public int getIsLock() {
return isLock;
}
public void setIsLock(int isLock) {
this.isLock = isLock;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getRoleid() {
return roleid;
}
public void setRoleid(int roleid) {
this.roleid = roleid;
}
public String getRolename() {
return rolename;
}
public void setRolename(String rolename) {
this.rolename = rolename;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public String getTel() {
return tel;
}
public void setTel(String tel) {
this.tel = tel;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
}
dbc
package mldn.lin.dbc;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
//mysql
public class DataBaseConnectionJDBC {
private static final String DBDRIVER="org.gjt.mm.mysql.Driver";
private static final String DBURL="jdbc:mysql://localhost:3306/ecside";
private static final String DBUSER="root";
private static final String DBPASSWORD="mysqladmin";
private Connection conn=null;
public DataBaseConnectionJDBC() {
super();
try {
Class.forName(DBDRIVER);
this.conn=DriverManager.getConnection(DBURL, DBUSER, DBPASSWORD);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}catch (SQLException e) {
e.printStackTrace();
}
}
//定义取得数据库连接的方法
public Connection getConnection(){
try {
if(this.conn==null || this.conn.isClosed()){
Class.forName(DBDRIVER);
conn=DriverManager.getConnection(DBURL, DBUSER, DBPASSWORD);
}
} catch (SQLException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
return conn;
}
//定义关闭数据库连接的方法
public void close(){
if(this.conn!=null){
try {
this.conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}
dao
package mldn.lin.dao;
import java.util.List;
import java.util.Map;
import mldn.lin.vo.Employee;
public interface IEmployeeDAO {
/**
* 添加记录的方法
* @param all 所有要添加的记录
* @return 是否插入成功
* @throws Exception
*/
public boolean doInsert(List<Employee> all)throws Exception;
/**
* 删除记录的方法
* @param ids 所有要删除的记录的主键值
* @return 是否删除成功
* @throws Exception
*/
public boolean doDelete(String[] usernames)throws Exception;
/**
* 更新记录的方法
* @param all 所有修改后的记录
* @return 是否修改成功
* @throws Exception
*/
public boolean doUpdate(List<Employee> all)throws Exception;
/**
* 查询全部记录的方法
* @param startRow 开始的记录数(索引)
* @param endRow 结束的记录(索引)
* @param searchMap 所有查询条件,key为字段名称,value为所要查询的关键字
* @param sortMap 所有排序条件,key为排序的字段名称,value为排序规则(升序、降序)
* @return 所有查询结果
* @throws Exception
*/
public List<Employee> doSelectAll(int startRow,int endRow,Map searchMap,Map sortMap)throws Exception;
/**
* 查询全部记录数
* @param searchMap 所有查询条件,key为字段名称,value为所要查询的关键字
* @return 返回符合条件的记录数,没有返回0
* @throws Exception
*/
public int getAllCount(Map searchMap)throws Exception;
}
dao_impl
package mldn.lin.impl;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import mldn.lin.dao.IEmployeeDAO;
import mldn.lin.dbc.DataBaseConnectionJDBC;
import mldn.lin.vo.Employee;
import org.ecside.util.ECSideUtils;
public class EmployeeDAOImpl implements IEmployeeDAO {
private DataBaseConnectionJDBC dbc;
public EmployeeDAOImpl (DataBaseConnectionJDBC dbc){
this.dbc=dbc;
}
public boolean doInsert(List<Employee> all) throws Exception {
// TODO Auto-generated method stub
String sql="INSERT INTO employee (username,password,name,tel,roleid,rolename,status,isLock) VALUES(?,?,?,?,?,?,?,?)";
PreparedStatement prmt=this.dbc.getConnection().prepareStatement(sql);
Iterator iter=all.iterator();
Employee emp=new Employee();
while(iter.hasNext()){
emp=(Employee) iter.next();
prmt.setString(1, emp.getUsername());
prmt.setString(2, emp.getPassword());
prmt.setString(3, emp.getName());
prmt.setString(4, emp.getTel());
prmt.setInt(5, emp.getRoleid());
prmt.setString(6, emp.getRolename());
prmt.setInt(7, emp.getStatus());
prmt.setInt(8, emp.getIsLock());
if(prmt.executeUpdate()==0){
return false;
}
}
return true;
}
public boolean doDelete(String[] usernames) throws Exception {
// TODO Auto-generated method stub
String sql="DELETE FROM employee WHERE username IN(";
for(int i=0;i<usernames.length;i++){
if(i<usernames.length-1){
sql+="?,";
}else{
sql+="?)";
}
}
PreparedStatement prmt=this.dbc.getConnection().prepareStatement(sql);
for(int i=0;i<usernames.length;i++){
prmt.setString(i+1, usernames[i]);
}
if(prmt.executeUpdate()>=0){
return true;
}
return false;
}
public boolean doUpdate(List<Employee> all) throws Exception {
// TODO Auto-generated method stub
String sql="UPDATE employee SET password=?,name=?,tel=?,roleid=?,rolename=?,status=?,isLock=? WHERE username=?";
PreparedStatement prmt=this.dbc.getConnection().prepareStatement(sql);
Iterator iter=all.iterator();
Employee emp=new Employee();
while(iter.hasNext()){
emp=(Employee) iter.next();
prmt.setString(1, emp.getPassword());
prmt.setString(2, emp.getName());
prmt.setString(3, emp.getTel());
prmt.setInt(4, emp.getRoleid());
prmt.setString(5, emp.getRolename());
prmt.setInt(6, emp.getStatus());
prmt.setInt(7, emp.getIsLock());
prmt.setString(8, emp.getUsername());
if(prmt.executeUpdate()==0){
return false;
}
}
return true;
}
public List<Employee> doSelectAll(int startRow, int endRow, Map searchMap,
Map sortMap) throws Exception {
// TODO Auto-generated method stub
String sql="SELECT username,password,name,tel,roleid,rolename,status,isLock FROM employee WHERE 1=1";
if(searchMap!=null){
Iterator iter=searchMap.entrySet().iterator();
if(iter.hasNext()){
sql+=" AND ";
Map.Entry entry=(Entry) iter.next();
if(entry.getKey().equals("roleid") || entry.getKey().equals("status") || entry.getKey().equals("isLock")){
sql+=entry.getKey()+"="+entry.getValue();
}else{
sql+=entry.getKey()+" LIKE '%"+entry.getValue()+"%'";
}
}
}
if(sortMap!=null){
sql+=" "+ ECSideUtils.getDefaultSortSQL(sortMap);
}
sql+=" LIMIT ?,?";
PreparedStatement prmt=this.dbc.getConnection().prepareStatement(sql);
prmt.setInt(1, startRow);
prmt.setInt(2, (endRow-startRow));
ResultSet rs=prmt.executeQuery();
List<Employee> all=null;
while(rs.next()){
if(all==null){
all=new ArrayList<Employee>();
}
Employee emp=new Employee();
emp.setUsername(rs.getString(1));
emp.setPassword(rs.getString(2));
emp.setName(rs.getString(3));
emp.setTel(rs.getString(4));
emp.setRoleid(rs.getInt(5));
emp.setRolename(rs.getString(6));
emp.setStatus(rs.getInt(7));
emp.setIsLock(rs.getInt(8));
all.add(emp);
}
return all;
}
public int getAllCount(Map searchMap) throws Exception {
// TODO Auto-generated method stub
String sql="SELECT count(*) FROM employee WHERE 1=1";
if(searchMap!=null){
Iterator iter=searchMap.entrySet().iterator();
if(iter.hasNext()){
sql+=" AND ";
Map.Entry entry=(Entry) iter.next();
if(entry.getKey().equals("roleid") || entry.getKey().equals("status") || entry.getKey().equals("isLock")){
sql+=entry.getKey()+"="+entry.getValue();
}else{
sql+=entry.getKey()+" LIKE '%"+entry.getValue()+"%'";
}
}
}
PreparedStatement prmt=this.dbc.getConnection().prepareStatement(sql);
ResultSet rs=prmt.executeQuery();
int count=0;
if(rs.next()){
count=rs.getInt(1);
}
return count;
}
}
dao_proxy
package mldn.lin.proxy;
import java.sql.PreparedStatement;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import mldn.lin.dao.IEmployeeDAO;
import mldn.lin.dbc.DataBaseConnectionJDBC;
import mldn.lin.impl.EmployeeDAOImpl;
import mldn.lin.vo.Employee;
public class EmployeeDAOProxy implements IEmployeeDAO {
private DataBaseConnectionJDBC dbc;
private IEmployeeDAO iemployeedao;
public EmployeeDAOProxy (){
this.dbc=new DataBaseConnectionJDBC();
this.iemployeedao=new EmployeeDAOImpl(this.dbc);
}
public boolean doInsert(List<Employee> all) throws Exception {
// TODO Auto-generated method stub
if(all==null){
return false;
}
this.dbc.getConnection().setAutoCommit(false);
boolean flag=false;
try {
flag=this.iemployeedao.doInsert(all);
if(flag){
this.dbc.getConnection().commit();
}else{
this.dbc.getConnection().rollback();
}
} catch (RuntimeException e) {
this.dbc.getConnection().rollback();
e.printStackTrace();
}finally{
this.dbc.close();
}
return true;
}
public boolean doDelete(String[] usernames) throws Exception {
// TODO Auto-generated method stub
if(usernames==null){
return false;
}
boolean flag=false;
try {
flag=this.iemployeedao.doDelete(usernames);
} catch (RuntimeException e) {
e.printStackTrace();
}finally{
this.dbc.close();
}
return flag;
}
public boolean doUpdate(List<Employee> all) throws Exception {
// TODO Auto-generated method stub
if(all==null){
return false;
}
this.dbc.getConnection().setAutoCommit(false);
boolean flag=false;
try {
flag=this.iemployeedao.doUpdate(all);
if(flag){
this.dbc.getConnection().commit();
}else{
this.dbc.getConnection().rollback();
}
} catch (RuntimeException e) {
this.dbc.getConnection().rollback();
e.printStackTrace();
}finally{
this.dbc.close();
}
return true;
}
public List<Employee> doSelectAll(int startRow, int endRow, Map searchMap,
Map sortMap) throws Exception {
// TODO Auto-generated method stub
List all=null;
try {
all=this.iemployeedao.doSelectAll(startRow, endRow, searchMap, sortMap);
} catch (RuntimeException e) {
e.printStackTrace();
}finally{
this.dbc.close();
}
return all;
}
public int getAllCount(Map searchMap) throws Exception {
// TODO Auto-generated method stub
int count=0;
try {
count=this.iemployeedao.getAllCount(searchMap);
} catch (RuntimeException e) {
e.printStackTrace();
}finally{
this.dbc.close();
}
return count;
}
}
factory
package mldn.lin.dao.factory;
import mldn.lin.dao.IEmployeeDAO;
import mldn.lin.dao.IRoleDAO;
import mldn.lin.proxy.EmployeeDAOProxy;
import mldn.lin.proxy.RoleDAOProxy;
public class DAOFactory {
public static IEmployeeDAO getIEmployeeDAOInstance(){
return new EmployeeDAOProxy();
}
}
四、建立超链接列表页
<%@ page language="java" pageEncoding="GBK"%>
<%
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>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<center>
<a href="employee.do?status=list">进入列表</a>
</center>
</body>
</html>
五、建立Action与ActionForm
ActionForm
/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package mldn.lin.struts.form;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
/**
* MyEclipse Struts
* Creation date: 05-13-2009
*
* XDoclet definition:
* @struts.form name="employForm"
*/
public class EmployForm extends ActionForm {
/*
* Generated fields
*/
/** status property */
private String status;
/*
* Generated Methods
*/
/**
* Method validate
* @param mapping
* @param request
* @return ActionErrors
*/
public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {
// TODO Auto-generated method stub
return null;
}
/**
* Method reset
* @param mapping
* @param request
*/
public void reset(ActionMapping mapping, HttpServletRequest request) {
// TODO Auto-generated method stub
}
/**
* Returns the status.
* @return String
*/
public String getStatus() {
return status;
}
/**
* Set the status.
* @param status The status to set
*/
public void setStatus(String status) {
this.status = status;
}
}
Action
/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package mldn.lin.struts.action;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import mldn.lin.dao.factory.DAOFactory;
import mldn.lin.struts.form.EmployForm;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;
import org.ecside.table.limit.Limit;
import org.ecside.util.RequestUtils;
/**
* MyEclipse Struts
* Creation date: 05-13-2009
*
* XDoclet definition:
* @struts.action path="/employ" name="employForm" input="/error.jsp" parameter="status" scope="request" validate="true"
*/
public class EmployAction extends DispatchAction {
/*
* Generated Methods
*/
/**
* Method execute
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
public ActionForward list(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
EmployForm employForm = (EmployForm) form;// TODO Auto-generated method stub
Limit limit=RequestUtils.getLimit(request);
Map searchMap=limit.getFilterSet().getPropertyValueMap();
Map sortMap=limit.getSort().getSortValueMap();
try {
int allRecorders = DAOFactory.getIEmployeeDAOInstance().getAllCount(searchMap);
int[] startEndRow=RequestUtils.getRowStartEnd(request, allRecorders, 5);
List all=DAOFactory.getIEmployeeDAOInstance().doSelectAll(startEndRow[0], startEndRow[1], searchMap, sortMap);
request.setAttribute("allEmployee", all);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return mapping.findForward("list");
}
}
web.xml
<?xml version="1.0" encoding="GBK"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>3</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>3</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<filter>
<filter-name>ecsideExport</filter-name>
<filter-class>org.ecside.filter.ECSideFilter</filter-class>
<init-param>
<param-name>useEasyDataAccess</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>useEncoding</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>encoding</param-name>
<param-value>GBK</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>ecsideExport</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
struts_config.xml
<?xml version="1.0" encoding="GBK"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd">
<struts-config>
<data-sources />
<form-beans >
<form-bean name="employForm" type="mldn.lin.struts.form.EmployForm" />
</form-beans>
<global-exceptions />
<global-forwards />
<action-mappings >
<action
attribute="employForm"
input="/error.jsp"
name="employForm"
parameter="status"
path="/employee"
scope="request"
type="mldn.lin.struts.action.EmployAction" >
<forward name="list" path="/list.jsp"></forward>
</action>
</action-mappings>
<message-resources parameter="mldn.lin.struts.ApplicationResources" />
</struts-config>
六、在列表页上导入ECSide的标签、支持js、样式表
<%@ page language="java" pageEncoding="GBK"%>
<%@ taglib uri="http://www.ecside.org" prefix="ec"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html:html lang="true">
<head>
<html:base />
<title>list.jsp</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<script type="text/javascript"
src="${pageContext.request.contextPath }/ecside/js/ecside_msg_gbk_cn.js"></script>
<script type="text/javascript"
src="${pageContext.request.contextPath }/ecside/js/prototype_mini.js"></script>
<script type="text/javascript"
src="${pageContext.request.contextPath }/ecside/js/ecside.js"></script>
<link rel="stylesheet" type="text/css"
href="${pageContext.request.contextPath }/ecside/css/ecside_style.css">
</head>
七、列表显示数据
<center>
<ec:table width="800" items="allEmployee" var="employee"
retrieveRowsCallback="limit" sortRowsCallback="limit"
filterRowsCallback="limit" action="employee.do?status=list"
useAjax="true" pageSizeList="2,5,10,50,all" rowsDisplayed="5"
title="" editable="true" xlsFileName="文件1.xls" csvFileName="文件2.csv"
pdfFileName="文件3.pdf" showPrint="true" sortable="true"
resizeColWidth="true" filterable="true"
updateAction="employee.do?status=update"
insertAction="employee.do?status=insert"
deleteAction="employee.do?status=delete" classic="true">
<ec:row recordKey="${employee.username}">
<ec:column property="username" title="用户名"></ec:column>
<ec:column property="password" title="密码"></ec:column>
<ec:column property="name" title="真实姓名"></ec:column>
<ec:column property="tel" title="联系方式"></ec:column>
<ec:column property="rolename" title="权限"></ec:column>
<ec:column property="status" title="是否休假"></ec:column>
<ec:column property="isLock" title="是否锁定"></ec:column>
</ec:row>
</ec:table>
</center>
八、实现查询功能
<center>
<ec:table width="800" items="allEmployee" var="employee"
retrieveRowsCallback="limit" sortRowsCallback="limit"
filterRowsCallback="limit" action="employee.do?status=list"
useAjax="true" pageSizeList="2,5,10,50,all" rowsDisplayed="5"
title="" editable="true" xlsFileName="文件1.xls" csvFileName="文件2.csv"
pdfFileName="文件3.pdf" showPrint="true" sortable="true"
resizeColWidth="true" filterable="true"
updateAction="employee.do?status=update"
insertAction="employee.do?status=insert"
deleteAction="employee.do?status=delete" classic="true">
<ec:row recordKey="${employee.username}">
<ec:column property="username" title="用户名"></ec:column>
<ec:column property="password" title="密码"></ec:column>
<ec:column property="name" title="真实姓名"></ec:column>
<ec:column property="tel" title="联系方式"></ec:column>
<ec:column property="rolename" title="权限"></ec:column>
<ec:column property="status" title="是否休假"></ec:column>
<ec:column property="isLock" title="是否锁定"></ec:column>
</ec:row>
</ec:table>
<!-- 编辑和过滤所使用的 通用的文本框模板 -->
<textarea id="ecs_t_date" rows="" cols="" style="display: none">
<input type="text" class="inputtext" value="" style="width: 100px;" name="" />
<input class="calendarImgButton" onclick="ECSideUtil.showCalendar(this)" type="button" id="date_button" />
</textarea>
<!-- 编辑和过滤所使用的 通用的文本框模板 -->
<textarea id="ecs_t_input" rows="" cols="" style="display: none">
<input type="text" class="inputtext" value="" onblur="ECSideUtil.updateEditCell(this)" style="width: 100%;" name="" />
</textarea>
</center>
发表评论
-
本小姐回来啦 —— 超级感谢MLDN
2009-08-10 13:24 1600我又回来了!哈哈,报告一个好消息,我已经成功入职博彦科 ... -
现在开始积极的找工作
2009-07-05 19:13 1176学习差不多了,得赶在毕业前找到一个工作啊,本小姐这段时 ... -
素质教育 —— 模拟面试
2009-06-30 19:10 1045今天一天都安排了职业素质的培养,包括简历的指导、技术面 ... -
EJB实体Bean开发的复合主键映射
2009-06-29 21:36 1686复合主键的映射:在Hibernate中是通过一个主键类来完成复 ... -
EJB实体Bean开发
2009-06-29 21:33 990EJB实体Bean开发的数据库连接采用数据源连接池的方式,因此 ... -
EJB3.0
2009-06-28 14:14 1233EJB是SUN公司提出的开发 ... -
JBoss服务器配置
2009-06-25 21:21 2079哦,哦,哦,EJB的准备课程啊。 这里开发使用的是 JB ... -
Spring结合iBATIS进行开发
2009-06-25 21:19 962使用Spring管理iBATIS完全可以参照Spring+Hi ... -
ibatis开发框架
2009-06-25 21:17 1258iBATIS为一个ORMapping框架,可以帮助开发人员完成 ... -
WebService分布式开发
2009-06-24 22:23 1907WebService:用来跨语言传递数据。 数据交互是通过XM ... -
北京下雨了
2009-06-18 19:56 772上次在公交车上,听到电视里放《北京下雨了》,那么北京今天 ... -
JQuery
2009-06-10 21:03 12621、JQuery的基本语法 ... -
AJAX中使用JSON
2009-06-10 21:02 1303在Java开发中,如果要使用JSON进行开发,需要一些支持,这 ... -
AJAX框架 —— JSON基本知识
2009-06-10 21:01 944我真想知道这年头到底有多少种框架。 1、JSON ... -
还应该多帮助同学,才能让自己进步快
2009-06-08 21:57 990今天对于本小姐来讲还真是相对轻松的一天啊,上周完成了任 ... -
业务、业务、业务。。。
2009-06-03 18:41 1142项目就是业务,项目中都是业务,技术就这么点东西,只要把 ... -
IBM Project 继续中ing....
2009-06-02 19:08 873项目就是要坚持的做下去,而且要想到做到最好,虽然框架很好 ... -
实际开发了
2009-06-01 18:17 879今天开始新的项目了,项目老师帮我们搭建好了SVN服务器, ... -
web学习笔记 —— 数据源
2009-05-31 19:56 1024使用数据源可以提升数据库的操作性能,当然,不管使用与否,对于程 ... -
SSH(Spring + Struts + Hibernate)
2009-05-31 19:47 2490Spring结合Hibernate ...
相关推荐
《ECSide:一个强大的JSP列表组件》 ECSide,全称为Extreme Components Side,是一个开源的JSP列表组件,源于eXtremeComponents项目,但已独立发展并拥有自己的特色。这个组件专注于提供列表的显示功能,同时支持单...
标题“ecside2.0最新版本”与描述“ecside2.0 2007年10月28日最新修正版”共同指向一个特定的软件更新,即ecside的2.0版本,它在2007年10月28日进行了最后一次修订。ecSide是一款基于Java的Web应用框架,专为构建...
EcSide2.0是一款基于Java开发的Web应用框架,它主要致力于简化Web应用程序的开发流程,提高开发效率。本教程将全面介绍如何使用EcSide2.0进行开发,特别是对于那些不熟悉Java Web或者对MVC(Model-View-Controller)...
### 分页组件ECSIDE文档知识点详述 #### 一、ECSIDE组件概述与功能实现 **ECSIDE**,作为一款专为Web应用程序设计的分页组件,其核心功能在于提供高效、灵活的数据展示解决方案。该组件源于**eXtremeComponents**...
ECSide是一款基于Java开发的Web项目管理工具,主要用于协助开发者进行Web应用的开发、调试和维护工作。这个压缩包包含的"Web项目所需ecside全部文件"是ECSide的完整组件,使得用户能够在本地环境中顺利运行和使用...
ecside2.0RC1项目包,引入即可运行,无需额外的jar包。 ECSide是有一个基于jsp tag的开源列表组件. 简单的说,它就是一组可以帮助你快速实现强大的列表的jsp标签. 它的工作原理很简单. 您将要展现的列表的数据集合...
【ECSide数据库分页、排序与过滤详解】 ECSide是一个用于Web应用程序的数据展示工具,它提供了便捷的方式来实现数据库中的数据分页、排序和过滤(简称RSF)功能。对于初学者而言,理解ECSide的工作原理和使用方法...
**ecside介绍** ecside,全称为"Eclipse Console for SQL and DDL Editor",是一款基于Eclipse平台的数据库管理工具。它专为数据库查询、数据编辑以及DDL(Data Definition Language)操作提供了一个集成的开发环境...
**ecside:强大的表格生成插件** ecside是一款专为开发者设计的表格处理工具,它在Web应用中扮演着至关重要的角色,能够高效地将后端数据转化为前端用户友好的表格展示。通过其丰富的功能和易用性,ecside使得处理...
ECSide是一款基于Java的网页表格控件,用于在网页上展示数据并提供各种操作功能。本文主要介绍ECSide的`<ec:table>`标签的使用方法和相关属性。 首先,ECSide的一些原版属性如`imagePath`、`showPagination`和`form...
**ECSide中文文档与实例详解** ECSide是一个基于Java的Web开发框架,它提供了一种高效、便捷的方式来构建数据驱动的Web应用。本资源包含了ECSide的中文文档、实例讲解以及2.0版本所需的类包,是理解并掌握ECSide...
超级详细的ecside标签部分属性说明 ecside标签是ECTable的一个组件,用于生成列表。下面是ecside标签部分属性的详细说明: 1. 属性:tableId 描述:设置列表的唯一标识,默认为"ec",当一个页面内有多个ECSIDE列表...
ECSide是一款基于Java开发的Web应用框架,主要用于构建数据驱动的管理界面。在"ecside2.0rc1源码及文档jar包等"这个压缩包中,包含的资源对于开发者来说是极其宝贵的,因为它提供了深入理解ECSide工作原理以及进行...
Java ECSide是一款基于Java开发的开源表格控件,主要用于数据展示和操作,它在Web应用中提供了强大的数据网格功能。ECSide的设计理念是提供一个轻量级、易用且功能丰富的表格组件,使得开发者可以方便地在网页上展示...
整理的ecside所需jar包: avalon-framework-4.0.jar batik-1.5-fop-0.20-5.jar commons-beanutils-bean-collections.jar commons-beanutils-core.jar commons-beanutils.jar commons-codec-...
标题中的"ecside所需的jar文件"指的就是与一个名为ecside的项目或框架相关的JAR文件集合。这些文件是开发者在使用ecside时必须包含的依赖,以便程序能够正常运行。 首先,我们来详细了解一下每个标签所代表的JAR...