From 193adf82bca63fca388cde2271717c32568619c3 Mon Sep 17 00:00:00 2001 From: Slavisa Baeldung Date: Thu, 26 May 2016 14:29:19 +0200 Subject: [PATCH] jsf-spring-integration - minor refactors --- .../controllers/RegistrationBean.java | 26 +++++----------- jsf/src/main/webapp/WEB-INF/web.xml | 8 ++--- jsf/src/main/webapp/index.xhtml | 31 ++++++++++--------- 3 files changed, 27 insertions(+), 38 deletions(-) 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 6d86f04ab1..635e4d48b8 100644 --- a/jsf/src/main/java/com/baeldung/springintegration/controllers/RegistrationBean.java +++ b/jsf/src/main/java/com/baeldung/springintegration/controllers/RegistrationBean.java @@ -10,28 +10,21 @@ import javax.faces.bean.ViewScoped; import javax.faces.context.FacesContext; import java.io.Serializable; - @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; + transient private IUserManagementDAO userDao; private String userName; private String operationMessage; - /** - * Creates a new instance of RegistrationBean - */ - public RegistrationBean() { - } - - public String createNewUser() { + public void createNewUser() { try { LOGGER.info("Creating new user"); FacesContext context = FacesContext.getCurrentInstance(); - boolean operationStatus = theUserDao.createUser(userName); + boolean operationStatus = userDao.createUser(userName); context.isValidationFailed(); if (operationStatus) { operationMessage = "User " + userName + " created"; @@ -39,8 +32,8 @@ public class RegistrationBean implements Serializable { } catch (Exception ex) { LOGGER.error("Error registering new user "); ex.printStackTrace(); + operationMessage = "Error " + userName + " not created"; } - return null; } public String getUserName() { @@ -51,15 +44,12 @@ public class RegistrationBean implements Serializable { this.userName = userName; } - /** - * @param theUserDao the theUserDao to set - */ - public void setTheUserDao(IUserManagementDAO theUserDao) { - this.theUserDao = theUserDao; + public void setUserDao(IUserManagementDAO userDao) { + this.userDao = userDao; } - public IUserManagementDAO getTheUserDao() { - return this.theUserDao; + public IUserManagementDAO getUserDao() { + return this.userDao; } public String getOperationMessage() { diff --git a/jsf/src/main/webapp/WEB-INF/web.xml b/jsf/src/main/webapp/WEB-INF/web.xml index 9345f201ef..3522338919 100644 --- a/jsf/src/main/webapp/WEB-INF/web.xml +++ b/jsf/src/main/webapp/WEB-INF/web.xml @@ -9,12 +9,8 @@ SERVER - - primefaces.PUBLIC_CAPTCHA_KEY - - - 6LdG-84SAAAAALQfp6DuJqd1XLnz3ZlHfhunPPjY - + javax.faces.FACELETS_SKIP_COMMENTS + true Faces Servlet diff --git a/jsf/src/main/webapp/index.xhtml b/jsf/src/main/webapp/index.xhtml index ff10f9c892..b37c864f2c 100644 --- a/jsf/src/main/webapp/index.xhtml +++ b/jsf/src/main/webapp/index.xhtml @@ -2,24 +2,27 @@ + xmlns:h="http://java.sun.com/jsf/html"> <h:outputText value="#{msg['message.welcome']}"/> - - - - - - - - - - - + + + + + + + + + +