diff --git a/jsf/pom.xml b/jsf/pom.xml index 6f43e08535..c4d4e333a1 100644 --- a/jsf/pom.xml +++ b/jsf/pom.xml @@ -13,6 +13,8 @@ 0.1-SNAPSHOT war + + com.sun.faces jsf-api @@ -25,6 +27,7 @@ + org.springframework spring-web @@ -46,6 +49,30 @@ ${org.springframework.version} + + + + org.slf4j + slf4j-api + ${org.slf4j.version} + + + ch.qos.logback + logback-classic + ${logback.version} + + + + org.slf4j + jcl-over-slf4j + ${org.slf4j.version} + + + + org.slf4j + log4j-over-slf4j + ${org.slf4j.version} + @@ -64,6 +91,12 @@ 4.2.5.RELEASE + + 2.1.7 + + + 1.7.13 + 1.1.3 \ No newline at end of file diff --git a/jsf/src/main/java/com/baeldung/springintegration/controllers/RegistrationBean.java b/jsf/src/main/java/com/baeldung/springintegration/controllers/RegistrationBean.java index b2cd505bd7..6d86f04ab1 100644 --- a/jsf/src/main/java/com/baeldung/springintegration/controllers/RegistrationBean.java +++ b/jsf/src/main/java/com/baeldung/springintegration/controllers/RegistrationBean.java @@ -1,31 +1,25 @@ -/* - * 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 org.slf4j.Logger; +import org.slf4j.LoggerFactory; 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 { + private static final Logger LOGGER = LoggerFactory.getLogger(RegistrationBean.class); @ManagedProperty(value = "#{userManagementDAO}") transient private IUserManagementDAO theUserDao; private String userName; private String operationMessage; - private boolean operationStatus; /** * Creates a new instance of RegistrationBean @@ -35,35 +29,24 @@ public class RegistrationBean implements Serializable { public String createNewUser() { try { - Logger.getAnonymousLogger().info("Creating new user"); + LOGGER.info("Creating new user"); FacesContext context = FacesContext.getCurrentInstance(); - operationStatus = theUserDao.createUser(userName); //DAO layer is used to register user using gathered data + boolean operationStatus = theUserDao.createUser(userName); context.isValidationFailed(); if (operationStatus) { - operationMessage = "User " + userName + " created"; } } catch (Exception ex) { - Logger.getAnonymousLogger().severe("Error registering new user "); + LOGGER.error("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; } @@ -79,16 +62,10 @@ public class RegistrationBean implements Serializable { 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; } diff --git a/jsf/src/main/resources/constraints.properties b/jsf/src/main/resources/constraints.properties deleted file mode 100644 index 00b6c57a88..0000000000 --- a/jsf/src/main/resources/constraints.properties +++ /dev/null @@ -1,10 +0,0 @@ -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 \ No newline at end of file diff --git a/jsf/src/main/resources/logback.xml b/jsf/src/main/resources/logback.xml new file mode 100644 index 0000000000..e9ae1894a6 --- /dev/null +++ b/jsf/src/main/resources/logback.xml @@ -0,0 +1,14 @@ + + + + + web - %date [%thread] %-5level %logger{36} - %message%n + + + + + + + + + \ No newline at end of file diff --git a/jsf/src/main/resources/messages.properties b/jsf/src/main/resources/messages.properties index bb665c259d..41e9622630 100644 --- a/jsf/src/main/resources/messages.properties +++ b/jsf/src/main/resources/messages.properties @@ -1,23 +1,3 @@ -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 +message.welcome = Baeldung | Register 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 diff --git a/jsf/src/main/webapp/index.xhtml b/jsf/src/main/webapp/index.xhtml index 3fc91ea376..ff10f9c892 100644 --- a/jsf/src/main/webapp/index.xhtml +++ b/jsf/src/main/webapp/index.xhtml @@ -3,22 +3,19 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> - - Baeldung | Register + <h:outputText value="#{msg['message.welcome']}"/> - + - + - +