Skip to content

Commit ef53002

Browse files
slavisaavramovicslavisa-baeldung
authored andcommitted
spring-jsf-integration - mavenizing
1 parent f972513 commit ef53002

File tree

16 files changed

+402
-0
lines changed

16 files changed

+402
-0
lines changed

jsf/pom.xml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<parent>
6+
<artifactId>parent-modules</artifactId>
7+
<groupId>com.baeldung</groupId>
8+
<version>1.0.0-SNAPSHOT</version>
9+
</parent>
10+
<modelVersion>4.0.0</modelVersion>
11+
12+
<artifactId>jsf</artifactId>
13+
<version>0.1-SNAPSHOT</version>
14+
<packaging>war</packaging>
15+
<dependencies>
16+
<!-- http://mvnrepository.com/artifact/com.sun.faces/mojarra-jsf-impl -->
17+
<dependency>
18+
<groupId>com.sun.faces</groupId>
19+
<artifactId>mojarra-jsf-impl</artifactId>
20+
<version>2.0.0-b04</version>
21+
</dependency>
22+
</dependencies>
23+
<build>
24+
<plugins>
25+
<plugin>
26+
<groupId>org.apache.maven.plugins</groupId>
27+
<artifactId>maven-compiler-plugin</artifactId>
28+
<version>3.5.1</version>
29+
<configuration>
30+
<source>1.8</source>
31+
<target>1.8</target>
32+
</configuration>
33+
</plugin>
34+
</plugins>
35+
</build>
36+
37+
</project>
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
/*
2+
* To change this template, choose Tools | Templates
3+
* and open the template in the editor.
4+
*/
5+
package com.baeldung.springintegration.controllers;
6+
7+
import com.baeldung.springintegration.dao.IUserManagementDAO;
8+
9+
import javax.faces.bean.ManagedBean;
10+
import javax.faces.bean.ManagedProperty;
11+
import javax.faces.bean.ViewScoped;
12+
import javax.faces.context.FacesContext;
13+
import java.io.Serializable;
14+
import java.util.logging.Logger;
15+
16+
/**
17+
*
18+
* @author Tayo
19+
*/
20+
@ManagedBean(name = "registration")
21+
@ViewScoped
22+
public class RegistrationBean implements Serializable {
23+
24+
@ManagedProperty(value = "#{userManagementDAO}")
25+
transient private IUserManagementDAO theUserDao;
26+
private String userName;
27+
private String operationMessage;
28+
private boolean operationStatus;
29+
30+
/**
31+
* Creates a new instance of RegistrationBean
32+
*/
33+
public RegistrationBean() {
34+
}
35+
36+
public String createNewUser() {
37+
try {
38+
Logger.getAnonymousLogger().info("Creating new user");
39+
FacesContext context = FacesContext.getCurrentInstance();
40+
operationStatus = theUserDao.createUser(userName); //DAO layer is used to register user using gathered data
41+
context.isValidationFailed();
42+
if (operationStatus) {
43+
44+
operationMessage = "User " + userName + " created";
45+
}
46+
} catch (Exception ex) {
47+
Logger.getAnonymousLogger().severe("Error registering new user ");
48+
ex.printStackTrace();
49+
}
50+
return null;
51+
}
52+
53+
public String returnHome() {
54+
return "home";
55+
}
56+
57+
/**
58+
* @return the name
59+
*/
60+
public String getUserName() {
61+
return userName;
62+
}
63+
64+
/**
65+
* @param userName the name to set
66+
*/
67+
public void setUserName(String userName) {
68+
this.userName = userName;
69+
}
70+
71+
/**
72+
* @param theUserDao the theUserDao to set
73+
*/
74+
public void setTheUserDao(IUserManagementDAO theUserDao) {
75+
this.theUserDao = theUserDao;
76+
}
77+
78+
public IUserManagementDAO getTheUserDao() {
79+
return this.theUserDao;
80+
}
81+
82+
/**
83+
* @return the operationMessage
84+
*/
85+
public String getOperationMessage() {
86+
return operationMessage;
87+
}
88+
89+
/**
90+
* @param operationMessage the operationMessage to set
91+
*/
92+
public void setOperationMessage(String operationMessage) {
93+
this.operationMessage = operationMessage;
94+
}
95+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* To change this template, choose Tools | Templates
3+
* and open the template in the editor.
4+
*/
5+
package com.baeldung.springintegration.dao;
6+
7+
8+
/**
9+
* @author Tayo
10+
*/
11+
public abstract class IUserManagementDAO implements UserManagementDAO {
12+
13+
14+
@Override
15+
public abstract boolean createUser(String userName);
16+
17+
18+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* To change this template, choose Tools | Templates
3+
* and open the template in the editor.
4+
*/
5+
package com.baeldung.springintegration.dao;
6+
7+
8+
/**
9+
* @author Tayo
10+
*/
11+
public interface UserManagementDAO {
12+
13+
public boolean createUser(String newUserData);
14+
15+
16+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* To change this template, choose Tools | Templates
3+
* and open the template in the editor.
4+
*/
5+
package com.baeldung.springintegration.dao;
6+
7+
import java.util.ArrayList;
8+
import java.util.List;
9+
import java.util.logging.Level;
10+
import java.util.logging.Logger;
11+
import javax.annotation.PostConstruct;
12+
13+
/**
14+
* @author Tayo
15+
*/
16+
public class UserManagementDAOImpl extends IUserManagementDAO {
17+
18+
private List<String> users;
19+
20+
@PostConstruct
21+
public void initUserList() {
22+
users = new ArrayList<String>();
23+
}
24+
25+
@Override
26+
public boolean createUser(String newUserData) {
27+
if (newUserData != null) {
28+
users.add(newUserData);
29+
Logger.getAnonymousLogger().log(Level.INFO, "User {0} successfully created", newUserData);
30+
return true;
31+
} else {
32+
return false;
33+
}
34+
}
35+
36+
public UserManagementDAOImpl() {
37+
}
38+
39+
40+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
userName.maxLength = 8
2+
userName.minLength = 4
3+
password.minLength = 8
4+
password.maxLength = 12
5+
zip.length = 5
6+
password.regexp = ^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{4,8}$
7+
safetext.regexp = ^[a-zA-Z0-9 .-]+$
8+
zip.regexp = ^\d{5}
9+
security.salt = G0d$3nd
10+
birthdate.format = MM dd yyyy
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
message.unmatchedPasswords = The passwords you have entered do not match
2+
message.valueRequired = This value is required
3+
message.invalidPassword = Your passwords must match and must contain at least one each of upper case letters, lower case letters, and digits.
4+
message.invalidDate = The date value supplied is invalid. It should be of the format MM/DD/YYYY
5+
message.invalidZip = Your zip code should be a 5 digit numeric value
6+
message.conversionError = An invalid value was supplied
7+
label.firstName = First Name
8+
label.lastName = Last Name
9+
label.username = Username
10+
label.firstPassword = Password
11+
label.confirmPassword = Confirm Password
12+
label.saveButton = Save
13+
label.cancelButton = Cancel
14+
label.returnHomeButton = Return
15+
label.dateOfBirth = Date of Birth
16+
label.city = City
17+
label.street = Street Address
18+
label.zip = Zip Code
19+
label.postal = Postal Code
20+
message.success = Operation Successful
21+
message.failure = Operation Failed
22+
account.success = Account Successfully created
23+
conversion.error = An invalid value was submitted for this field
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Context antiJARLocking="true" path="/Baeldung"/>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<beans xmlns="http://www.springframework.org/schema/beans"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xmlns:context="http://www.springframework.org/schema/context/spring-context-2.5.xsd"
5+
xmlns:lang="http://www.springframework.org/schema/lang/spring-lang-2.5.xsd"
6+
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
7+
http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springframework.org/schema/context/spring-context-2.5.xsd/spring-spring-context-2.5.xsd-3.1.1.RELEASE.xsd
8+
http://www.springframework.org/schema/jee/spring-jee-2.5.xsd http://www.springframework.org/schema/jee/spring-jee-2.5.xsd/spring-spring-jee-2.5.xsd-3.1.1.RELEASE.xsd
9+
http://www.springframework.org/schema/lang/spring-lang-2.5.xsd http://www.springframework.org/schema/lang/spring-lang-2.5.xsd/spring-spring-lang-2.5.xsd-3.1.1.RELEASE.xsd
10+
">
11+
12+
<bean class="org.springframework.context.annotation.CommonAnnotationBeanPostProcessor" />
13+
<bean class="com.baeldung.dao.UserManagementDAOImpl" id="userManagementDAO"/>
14+
15+
</beans>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<bindings
2+
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
3+
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
4+
wsdlLocation="http://localhost:8084/AxiaTest/TestIt?wsdl"
5+
xmlns="http://java.sun.com/xml/ns/jaxws">
6+
<bindings node="wsdl:definitions">
7+
<package name="com.me.transport.test"/>
8+
<enableAsyncMapping>true</enableAsyncMapping>
9+
10+
</bindings>
11+
</bindings>

0 commit comments

Comments
 (0)