spring-jsf-integration - mavenizing
This commit is contained in:
committed by
Slavisa Baeldung
parent
f972513e2b
commit
ef53002000
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.baeldung.springintegration.controllers;
|
||||
|
||||
import com.baeldung.springintegration.dao.IUserManagementDAO;
|
||||
|
||||
import javax.faces.bean.ManagedBean;
|
||||
import javax.faces.bean.ManagedProperty;
|
||||
import javax.faces.bean.ViewScoped;
|
||||
import javax.faces.context.FacesContext;
|
||||
import java.io.Serializable;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Tayo
|
||||
*/
|
||||
@ManagedBean(name = "registration")
|
||||
@ViewScoped
|
||||
public class RegistrationBean implements Serializable {
|
||||
|
||||
@ManagedProperty(value = "#{userManagementDAO}")
|
||||
transient private IUserManagementDAO theUserDao;
|
||||
private String userName;
|
||||
private String operationMessage;
|
||||
private boolean operationStatus;
|
||||
|
||||
/**
|
||||
* Creates a new instance of RegistrationBean
|
||||
*/
|
||||
public RegistrationBean() {
|
||||
}
|
||||
|
||||
public String createNewUser() {
|
||||
try {
|
||||
Logger.getAnonymousLogger().info("Creating new user");
|
||||
FacesContext context = FacesContext.getCurrentInstance();
|
||||
operationStatus = theUserDao.createUser(userName); //DAO layer is used to register user using gathered data
|
||||
context.isValidationFailed();
|
||||
if (operationStatus) {
|
||||
|
||||
operationMessage = "User " + userName + " created";
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
Logger.getAnonymousLogger().severe("Error registering new user ");
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String returnHome() {
|
||||
return "home";
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name
|
||||
*/
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param userName the name to set
|
||||
*/
|
||||
public void setUserName(String userName) {
|
||||
this.userName = userName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param theUserDao the theUserDao to set
|
||||
*/
|
||||
public void setTheUserDao(IUserManagementDAO theUserDao) {
|
||||
this.theUserDao = theUserDao;
|
||||
}
|
||||
|
||||
public IUserManagementDAO getTheUserDao() {
|
||||
return this.theUserDao;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the operationMessage
|
||||
*/
|
||||
public String getOperationMessage() {
|
||||
return operationMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param operationMessage the operationMessage to set
|
||||
*/
|
||||
public void setOperationMessage(String operationMessage) {
|
||||
this.operationMessage = operationMessage;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.baeldung.springintegration.dao;
|
||||
|
||||
|
||||
/**
|
||||
* @author Tayo
|
||||
*/
|
||||
public abstract class IUserManagementDAO implements UserManagementDAO {
|
||||
|
||||
|
||||
@Override
|
||||
public abstract boolean createUser(String userName);
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.baeldung.springintegration.dao;
|
||||
|
||||
|
||||
/**
|
||||
* @author Tayo
|
||||
*/
|
||||
public interface UserManagementDAO {
|
||||
|
||||
public boolean createUser(String newUserData);
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.baeldung.springintegration.dao;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
/**
|
||||
* @author Tayo
|
||||
*/
|
||||
public class UserManagementDAOImpl extends IUserManagementDAO {
|
||||
|
||||
private List<String> users;
|
||||
|
||||
@PostConstruct
|
||||
public void initUserList() {
|
||||
users = new ArrayList<String>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createUser(String newUserData) {
|
||||
if (newUserData != null) {
|
||||
users.add(newUserData);
|
||||
Logger.getAnonymousLogger().log(Level.INFO, "User {0} successfully created", newUserData);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public UserManagementDAOImpl() {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
userName.maxLength = 8
|
||||
userName.minLength = 4
|
||||
password.minLength = 8
|
||||
password.maxLength = 12
|
||||
zip.length = 5
|
||||
password.regexp = ^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{4,8}$
|
||||
safetext.regexp = ^[a-zA-Z0-9 .-]+$
|
||||
zip.regexp = ^\d{5}
|
||||
security.salt = G0d$3nd
|
||||
birthdate.format = MM dd yyyy
|
||||
@@ -0,0 +1,23 @@
|
||||
message.unmatchedPasswords = The passwords you have entered do not match
|
||||
message.valueRequired = This value is required
|
||||
message.invalidPassword = Your passwords must match and must contain at least one each of upper case letters, lower case letters, and digits.
|
||||
message.invalidDate = The date value supplied is invalid. It should be of the format MM/DD/YYYY
|
||||
message.invalidZip = Your zip code should be a 5 digit numeric value
|
||||
message.conversionError = An invalid value was supplied
|
||||
label.firstName = First Name
|
||||
label.lastName = Last Name
|
||||
label.username = Username
|
||||
label.firstPassword = Password
|
||||
label.confirmPassword = Confirm Password
|
||||
label.saveButton = Save
|
||||
label.cancelButton = Cancel
|
||||
label.returnHomeButton = Return
|
||||
label.dateOfBirth = Date of Birth
|
||||
label.city = City
|
||||
label.street = Street Address
|
||||
label.zip = Zip Code
|
||||
label.postal = Postal Code
|
||||
message.success = Operation Successful
|
||||
message.failure = Operation Failed
|
||||
account.success = Account Successfully created
|
||||
conversion.error = An invalid value was submitted for this field
|
||||
Reference in New Issue
Block a user