package control.action;
import java.util.Iterator;
import model.beans.User;
import model.service.UserService;
import control.util.Constants;
import control.util.PageAction;
@SuppressWarnings("serial")
public class UserAction extends PageAction {
private UserService userService;
private String userID;
private String username;
private String password;
private String password2;
private String realname;
private String sex;
private String telephone;
private String position;
private String choise;
private String choisename;
public String getChoise() {
return choise;
}
public void setChoise(String choise) {
this.choise = choise;
}
public String getChoisename() {
return choisename;
}
public void setChoisename(String choisename) {
this.choisename = choisename;
}
public String getRealname() {
return realname;
}
public void setRealname(String realname) {
this.realname = realname;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public String getTelephone() {
return telephone;
}
public void setTelephone(String telephone) {
this.telephone = telephone;
}
public String getPosition() {
return position;
}
public void setPosition(String position) {
this.position = position;
}
public String getUserID() {
return userID;
}
public void setUserID(String userID) {
this.userID = userID;
}
public UserService getUserService() {
return userService;
}
public void setUserService(UserService userService) {
this.userService = userService;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getPassword2() {
return password2;
}
public void setPassword2(String password2) {
this.password2 = password2;
}
@Override
public void validate() {
clearErrorsAndMessages();
}
public String select() throws Exception {
// 清除错误消息
clearErrorsAndMessages();
return Constants.ADD_USER;
}
public String init() throws Exception {
// 清除错误消息
clearErrorsAndMessages();
// 重设分页参数
super.pageSize = Constants.pageSize;
super.pageNo = Constants.pageNo;
// 取得当前分页数据
super.pager = this.userService.list(super.pageSize, super.pageNo);
// 保存分页数据
setSession(Constants.USER_LIST, super.pager);
return Constants.LIST_KEY;
}
public String list() throws Exception {
// 清除错误消息
clearErrorsAndMessages();
// 取得当前分页数据
super.pager = this.userService.list(super.pageSize, super.pageNo);
// 保存分页数据
setSession(Constants.USER_LIST, super.pager);
return Constants.LIST_KEY;
}
public String delete() throws Exception {
// 清除错误消息
clearErrorsAndMessages();
// id为空时返回错误
if (this.getUserID() == null) {
} else {
// 删除数据
this.userService.delete(this.getUserID());
}
// 取得当前页的数据
super.pager = this.userService.list(super.pageSize, super.pageNo);
return Constants.LIST_KEY;
}
// 请求addressEdit.do的处理函数
public String edit() throws Exception {
// 清除错误消息
clearErrorsAndMessages();
if (this.getUserID() == null) {
return Constants.LIST_KEY;
} else {
User record = this.getUserService().select(this.getUserID(), 2);
if (record == null) {
return Constants.LIST_KEY;
} else {
bean2Form(record);
return Constants.EDIT_KEY;
}
}
}
private void bean2Form(User record) {
this.setUserID(record.getUserId());
this.setUsername(record.getUserName());
this.setPassword(record.getPassword());
this.setRealname(record.getRealName());
this.setSex(record.getSex());
this.setTelephone(record.getTelephone());
this.setPosition(record.getPosition());
}
public String insert() throws Exception {
// 清除错误消息
clearErrorsAndMessages();
User record = new User();
record.setUserId(this.getUserID());
record.setUserName(this.getUsername());
record.setPassword(this.getPassword());
record.setRealName(this.getRealname());
record.setSex(this.getSex());
record.setTelephone(this.getTelephone());
record.setPosition(this.getPosition());
if (this.getUserService().insert(record)) {
// 取得当前页的数据
super.pager = this.userService.list(super.pageSize, super.pageNo);
return Constants.LIST_KEY;
} else {
return Constants.ADD_USER;
}
}
public String update() throws Exception {
// 清除错误消息
clearErrorsAndMessages();
User record = new User();
record = this.userService.select(this.getUserID(), 2);
record.setUserId(record.getUserId());
record.setUserName(record.getUserName());
record.setPassword(record.getPassword());
record.setRealName(this.getRealname());
record.setSex(record.getSex());
record.setTelephone(this.getTelephone());
record.setPosition(this.getPosition());
if (this.getUserService().update(record)) {
// 给表单字段赋值
bean2Form(record);
// 取得当前页的数据
super.pager = this.userService.list(super.pageSize, super.pageNo);
return Constants.LIST_KEY;
} else {
return Constants.EDIT_KEY;
}
}
public String search() throws Exception {
// 清除错误消息
clearErrorsAndMessages();
Constants.RECORD = null;
Constants.USER = null;
if (this.getChoise().equals("姓名")) {
if (this.getChoisename() == null) {
super.pager = this.userService.list(super.pageSize,
super.pageNo);
return Constants.LIST_KEY;
} else {
Iterator<User> record = this.userService.select(this.getChoisename());
Constants.RECORD = record;
return Constants.SEARCH_KEY;
}
} else if (this.getChoise().equals("用户编号")) {
if (this.getChoisename() == null) {
super.pager = this.userService.list(super.pageSize,
super.pageNo);
return Constants.LIST_KEY;
} else {
User record = this.userService.select(this.getChoisename(), 2);
Constants.USER = record;
return Constants.SEARCH_KEY;
}
}
return Constants.LIST_KEY;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
ssh2-netbeans (318个子文件)
styles.css 1KB
Entries 3KB
Entries 1KB
Entries 1KB
Entries 1KB
Entries 1020B
Entries 651B
Entries 358B
Entries 356B
Entries 287B
Entries 261B
Entries 241B
Entries 214B
Entries 157B
Entries 129B
Entries 89B
Entries 87B
Entries 86B
Entries 85B
Entries 83B
Entries 65B
Entries 63B
Entries 45B
Entries 44B
Entries 43B
Entries 26B
undefine.gif 17KB
REG.GIF 3KB
search1.gif 2KB
NAV_SEPARATE.GIF 261B
CEN_SEPARATE.GIF 79B
BG.GIF 52B
spring.jar 2.57MB
struts2-core-2.0.9.jar 2.1MB
hibernate3.jar 1.6MB
jgroups-2.2.7.jar 1.58MB
ant-1.6.2.jar 977KB
hibernate2.jar 945KB
freemarker-2.3.8.jar 784KB
jboss-jmx.jar 578KB
jboss-common.jar 570KB
mysql-connector-java-5.0.8-bin.jar 528KB
dom4j-1.4.jar 475KB
proxool-0.8.3.jar 465KB
xwork-2.0.4.jar 445KB
antlr-2.7.5H3.jar 423KB
c3p0-0.8.5.jar 389KB
jboss-cache.jar 366KB
antlr-2.7.2.jar 350KB
log4j-1.2.12.jar 350KB
log4j-1.2.8.jar 344KB
log4j-1.2.9.jar 344KB
dom4j-1.5.2.jar 305KB
cglib-full-2.0.2.jar 301KB
cglib-2.1.jar 275KB
jaxen-1.1-beta-4.jar 233KB
jboss-system.jar 218KB
sitemesh-2.4.jar 177KB
commons-collections-2.1.1.jar 171KB
concurrent-1.3.2.jar 167KB
commons-lang-2.0.jar 166KB
ognl-2.6.11.jar 164KB
cleanimports.jar 139KB
xml-apis.jar 121KB
junit-3.8.1.jar 118KB
commons-validator-1.3.0.jar 117KB
commons-beanutils-1.6.jar 116KB
oscache-2.1.jar 112KB
commons-dbcp-1.2.1.jar 105KB
jaas.jar 102KB
commons-chain-1.1.jar 88KB
ant-junit-1.6.2.jar 72KB
oro-2.0.8.jar 64KB
ehcache-0.9.jar 52KB
ehcache-1.1.jar 46KB
commons-logging-api-1.1.jar 44KB
commons-pool-1.2.jar 41KB
commons-logging.jar 37KB
commons-logging-1.0.4.jar 37KB
swarmcache-1.0rc2.jar 30KB
asm.jar 26KB
jacc-1_0-fr.jar 24KB
connector.jar 18KB
asm-attrs.jar 16KB
geronimo-spec-jta-1.0.1B-rc2.jar 13KB
odmg-3.0.jar 13KB
jta.jar 9KB
ant-launcher-1.6.2.jar 8KB
struts2-spring-plugin-2.0.9.jar 8KB
ant-swing-1.6.2.jar 7KB
jdbc2_0-stdext.jar 7KB
versioncheck.jar 6KB
ant-antlr-1.6.2.jar 6KB
UserAction.java 8KB
BusinessmanAction.java 7KB
RichangAction.java 7KB
CustomerDAOImpl.java 6KB
BusinessmanDAOImpl.java 6KB
GoodsouthousemenuDAOImpl.java 5KB
SalemenuDAOImpl.java 5KB
共 318 条
- 1
- 2
- 3
- 4
热情的破坏者
- 粉丝: 5
- 资源: 145
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
前往页