首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

liferay6.1的SSI调整2(SDK开发)

2012-11-19 
liferay6.1的SSI整合2(SDK开发)UserAction:package com.actionimport java.util.Listimport com.opensym

liferay6.1的SSI整合2(SDK开发)
UserAction:

package com.action;import java.util.List;import com.opensymphony.xwork2.ActionSupport;import com.service.IUserService;import com.vo.User;public class UserAction extends ActionSupport{private static final long serialVersionUID = 3836787603947654532L;private IUserService userService;    private  List<User> userList;    private User user;    public User getUser() {return user;}public void setUser(User user) {this.user = user;}public List<User> getUserList() {return userList;}public void setUserList(List<User> userList) {this.userList = userList;}public IUserService getUserService() {return userService;}public void setUserService(IUserService userService) {this.userService = userService;}public String findAllUsers() throws Exception {System.out.println("find--user");        userList = userService.findAllUsers();    System.out.println("find over----------------");return "finduser";}public String ssi()throws Exception{System.out.println("index...action");return "view";}public String addUser()throws Exception{System.out.println("name---"+user.getName());System.out.println("name---"+user.getAge());userService.addUser(user);return "addUserSuccess";}}


DAO层 IUserDao :
package com.dao;import java.util.List;import com.vo.User;public interface IUserDao {public List<User> findAllUsers();        public User findUserByKey(int id);        public void deleteUser(User user);public void addUser(User user);public void updateUser(User user);}


DAO层 UserDao
package com.daoImpl;import java.util.List;import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;import com.dao.IUserDao;import com.ibatis.sqlmap.client.SqlMapClient;import com.vo.User;public class UserDao extends SqlMapClientDaoSupport implements IUserDao {public void addUser(User user) {this.getSqlMapClientTemplate().insert("saveUser", user);}public void deleteUser(User user) {this.getSqlMapClientTemplate().delete("deleteUser", user);}public List<User> findAllUsers() {List<User> list = null;list = this.getSqlMapClientTemplate().queryForList("getAllUsers");return list;}public User findUserByKey(int id) {User user = null;user = (User) this.getSqlMapClientTemplate().queryForObject("findUserById", id);return user;}public void updateUser(User user) {this.getSqlMapClientTemplate().update("updateUser", user);}}


Service 层 UserServiceImpl
package com.serviceImpl;import java.util.List;import org.springframework.orm.ibatis.SqlMapClientTemplate;import com.dao.IUserDao;import com.ibatis.sqlmap.client.SqlMapClient;import com.service.IUserService;import com.vo.User;public class UserServiceImpl extends SqlMapClientTemplate implementsIUserService {private IUserDao userDao;public IUserDao getUserDao() {return userDao;}public void setUserDao(IUserDao userDao) {this.userDao = userDao;}public void addUser(User user) {userDao.addUser(user);}public void deleteUser(User user) {userDao.deleteUser(user);}public List<User> findAllUsers() {return userDao.findAllUsers();}public void updateUser(User user) {userDao.updateUser(user);}@Overridepublic User findUserByKey(int id) {return userDao.findUserByKey(id);}}


Service层 IUserService
package com.service;import java.util.List;import com.vo.User;public interface IUserService {public List<User> findAllUsers();public User findUserByKey(int id);public void deleteUser(User user);public void addUser(User user);public void updateUser(User user);}


实体类:User
package com.vo;import java.io.Serializable;public class User implements Cloneable, Serializable {private static final long serialVersionUID = -9103289450003300385L;private int id;private String name;private String age;public int getId() {return id;}public void setId(int id) {this.id = id;}public String getName() {return name;}public void setName(String name) {this.name = name;}public String getAge() {return age;}public void setAge(String age) {this.age = age;}}

热点排行