/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.library.entity;
/**
*
* @author 窦星磊
*/
import java.util.*;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.validator.*;
import java.util.Date;
import javax.faces.component.html.HtmlInputSecret;
@ManagedBean
@RequestScoped
public class Utils{
private Date today;
private String email;
private String password;
private String passwordagain;
private String difficulty;
private static List<User> userlist=new LinkedList<User>();;
public Utils(){
today=new Date();
email="";
password="";
passwordagain="";
difficulty="";
}
public Date getToday(){
return today;
}
public void setToday(Date today){
this.today=today;
}
public String getEmail(){
return email;
}
public void setEmail(String email){
this.email=email;
}
public String getPassword(){
return password;
}
public void setPassword(String password){
this.password=password;
}
public String getPasswordagain(){
return passwordagain;
}
public void setPasswordagain(String passwordagain){
this.passwordagain=passwordagain;
}
public String getDifficulty(){
return difficulty;
}
public void setDifficulty(String difficulty){
this.difficulty=difficulty;
}
public String loginValidate(){
if(userlist.isEmpty()){
return "failure";
}
for(User u:userlist){
if(u.getEmail().equals(email) && u.getPassword().equals(password)){
return "success";
}
}
return "failure";
}
public String signup(){
User user=new User();
user.setEmail(email);
user.setPassword(password);
userlist.add(user);
return "done";
}
public void emailRepeatValidate(FacesContext context, UIComponent component, Object value) throws ValidatorException {
if(userlist.isEmpty()){
return;
}
for(User u:userlist){
if(u.getEmail().equals(value.toString().trim())){
FacesMessage msg = new FacesMessage("邮箱已被注册过。");
msg.setSeverity(FacesMessage.SEVERITY_ERROR);
throw new ValidatorException(msg);
}
}
}
public void passwordNotSameValidate(FacesContext context, UIComponent component, Object value) throws ValidatorException {
UIComponent c = null;
for(UIComponent ui : component.getParent().getChildren()){
if("password".equals(ui.getId())){
c = ui;
break;
}
}
HtmlInputSecret htmlInputSecret = (HtmlInputSecret)c;
if (!value.toString().trim().equals(htmlInputSecret.getValue())) {
FacesMessage msg = new FacesMessage("两次密码输入不一致!");
throw new ValidatorException(msg);
}
}
}
JSF框架使用示例.rar_JSF
版权申诉
95 浏览量
2022-09-24
09:14:10
上传
评论
收藏 361KB RAR 举报
weixin_42653672
- 粉丝: 93
- 资源: 1万+
最新资源
- python tkinter-08-盒子模型.ev4.rar
- Doozy UI Manager 2023
- 基于matlab实现夜间车牌识别程序(1).rar
- 基于matlab实现无线传感器网络无需测距定位算法matlab源代码 包括apit,dv-hop,amorphous在内的共7个
- 基于python的yolov5实现的旋转目标检测
- 基于matlab实现无线传感器网络 CAB定位仿真程序 这是无线传感器节点定位CAB算法的仿真程序,由matlab完成.rar
- 基于matlab实现图像处理,本程序使用背景差分法对来往车辆进行检测和跟踪.rar
- 基于matlab实现视频监控中车型识别代码,自己写的,希望和大家多多交流.rar
- springcodespringcodespringcodespringcode
- 基于matlab实现权值的MAXDEV无线传感器网络定位算法研究 MAXDEV 无线传感器 定位 算法.rar
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈