📄 common_001_view.java
字号:
package com.hb.base.view.common;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Logger;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.log.Log;
import org.jboss.seam.security.Identity;
import com.hb.base.domain.common.Person;
import com.hb.base.services.common.ICommonService;
import com.hb.base.view.domain.AbstractViewBean;
import com.hb.base.view.domain.UserInfoSessionBean;
/**
* 2008/03/07
*
* @author 何 貝
*/
@Scope(ScopeType.EVENT)
@Name("Common_001_View")
public class Common_001_View extends AbstractViewBean {
private static final long serialVersionUID = 4760644324811295557L;
@Logger
private Log log;
@In
Identity identity;
@In("#{commonService}")
private ICommonService commonService;
@Override
public void create() {
}
@Override
public void destroy() {
}
@Override
public void init() {
}
/**
* 用户登录
*/
public boolean login_Action() {
log.debug("authenticating #0 #1", identity.getUsername(), identity.getPassword());
// 用户登录
boolean loginSuccess = commonService
.userLogin_Service(identity.getUsername(), identity.getPassword());
if (loginSuccess) {// 用户登录成功
// 登录用户信息
UserInfoSessionBean userInfo = initUserInfo();
saveUserInfo(userInfo);
}
return loginSuccess;
}
/**
* 用户注销
*/
public String logout_Action() {
removeUserInfo();
identity.logout();
return "/home.xhtml";
}
/**
* 初始化 登录用户信息
*/
private UserInfoSessionBean initUserInfo() {
// 取得个人信息
Person p = commonService.getPersonInfoByEmployeeID_Service(identity.getUsername());
// 用户信息
UserInfoSessionBean userInfo = new UserInfoSessionBean();
userInfo.setUserId(identity.getUsername());
userInfo.setPersonId(p.getPersonID());
userInfo.setUserName(p.getName());
return userInfo;
}
// --------------------------------------------------------------------------
// public String getUsername() {
// return username;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setUsername(String username) {
// this.username = username;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -