日期:2014-05-17 浏览次数:20768 次
package com.hollycrm.hollyv8.zsptest.zsp.action; import java.util.List; import javax.servlet.http.HttpServletRequest; import org.apache.log4j.Logger; import org.apache.struts2.interceptor.ServletRequestAware; import com.experiment.vo.UserInfo; import com.hollycrm.hollyv8.organization.user.action.UserAction; import com.hollycrm.hollyv8.zsptest.zsp.service.UserManagerService; import com.opensymphony.xwork2.ActionSupport; public class ZspAction extends ActionSupport implements ServletRequestAware{ private HttpServletRequest request; private static final long serialVersionUID = 8729730792551753250L; private static Logger logger = Logger.getLogger(UserAction.class); public void setServletRequest(HttpServletRequest request) { this.request=request; } public String ZspAction(){ return "list_success"; } private UserManagerService userManager; private List<UserInfo> users; private UserInfo user; private String id; private String account; private String name; private String birthday; private String sex; private String[] ids; public String[] getIds() { return ids; } public void setIds(String[] ids) { this.ids = ids; } public UserManagerService getUserManager() { return userManager; } public void setUserManager(UserManagerService userManager) { this.userManager = userManager; } public List<UserInfo> getUsers() { return users; } public void setUsers(List<UserInfo> users) { this.users = users; } public UserInfo getUser() { return user; } public void setUser(UserInfo user) { this.user = user; } public String getId() { return id; } public void setId(String id) { this.id = id; } public String getAccount() { return account; } public void setAccount(String account) { this.account = account; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getBirthday() { return birthday; } public void setBirthday(String birthday) { this.birthday = birthday; } public String getSex() { return sex; } public void setSex(String sex) { this.sex = sex; } public String add() { if (this.userManager.getUser(user.getName(),user.getAccount()) != null) { return INPUT; } else { this.userManager.addUser(user); return "success_add"; } } public String list() { this.users = this.userManager.listUser(); if (this.users.size() > 0) { return "list1_success"; // return SUCCESS; } else { return INPUT; } } public String delete() { if (this.id !="0" ) { this.userManager.deleteUser(this.id); } else { if (ids.length > 0) { for (String id : ids) { this.userManager.deleteUser(id); } } }