📄 loginbean.java
字号:
package org.fireflow.example.mbeans;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpSession;
import org.fireflow.example.ou.OUManagementMock;
import org.fireflow.example.ou.User;
public class LoginBean {
private String userId = null;
private String userPwd = null;
private User currentUser = null;
/*
* 登陆系统
*/
public String doLogin(){
OUManagementMock ouMgr = OUManagementMock.getInstance();
currentUser = ouMgr.checkUser(userId, userPwd);
FacesContext facesCtx = FacesContext.getCurrentInstance();
HttpSession httpSession = (HttpSession)facesCtx.getExternalContext().getSession(true);
if (currentUser!=null){
httpSession.setAttribute("CURRENT_USER", currentUser);
return "MAIN_PAGE";
}else{
FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_ERROR,
"错误:", "用户名或者密码错误。");
facesCtx.addMessage(null, msg);
return "SEFL";
}
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getUserPwd() {
return userPwd;
}
public void setUserPwd(String userPwd) {
this.userPwd = userPwd;
}
public User getCurrentUser() {
FacesContext facesCtx = FacesContext.getCurrentInstance();
HttpSession httpSession = (HttpSession)facesCtx.getExternalContext().getSession(true);
currentUser = (User)httpSession.getAttribute("CURRENT_USER");
return currentUser;
}
public void setCurrentUser(User currentUser) {
this.currentUser = currentUser;
}
public boolean getRight1(){
User u = this.getCurrentUser();
if (u.getId().startsWith("Cashier")){
return true;
}
return false;
}
public boolean getRight2(){
User u = this.getCurrentUser();
if (u.getId().startsWith("WarehouseKeeper")){
return true;
}
return false;
}
public boolean getRight3(){
User u = this.getCurrentUser();
if (u.getId().startsWith("Deliveryman")){
return true;
}
return false;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -