Skip to content

Commit b5e4c4e

Browse files
jboadasmaibin
authored andcommitted
Converters, Listeners and Validators in Java EE 7 (eugenp#1630)
1 parent 3fd20f6 commit b5e4c4e

9 files changed

Lines changed: 181 additions & 6 deletions

File tree

‎jee7/pom.xml‎

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
<artifactId>jee7</artifactId>
88
<version>1.0-SNAPSHOT</version>
99
<description>JavaEE 7 Arquillian Archetype Sample</description>
10-
<packaging>war</packaging>
1110

1211
<properties>
1312
<java.min.version>1.8</java.min.version>
@@ -28,6 +27,7 @@
2827

2928
<maven-compiler-plugin.version>3.6.0</maven-compiler-plugin.version>
3029
<maven-war-plugin.version>2.6</maven-war-plugin.version>
30+
<maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
3131
</properties>
3232

3333
<prerequisites>
@@ -43,6 +43,13 @@
4343
<scope>import</scope>
4444
<type>pom</type>
4545
</dependency>
46+
<dependency>
47+
<groupId>org.jboss.arquillian.extension</groupId>
48+
<artifactId>arquillian-drone-bom</artifactId>
49+
<version>2.0.1.Final</version>
50+
<type>pom</type>
51+
<scope>import</scope>
52+
</dependency>
4653
</dependencies>
4754
</dependencyManagement>
4855

@@ -65,6 +72,13 @@
6572
<artifactId>arquillian-junit-container</artifactId>
6673
<scope>test</scope>
6774
</dependency>
75+
<dependency>
76+
<groupId>org.jboss.arquillian.graphene</groupId>
77+
<artifactId>graphene-webdriver</artifactId>
78+
<version>2.1.0.Final</version>
79+
<type>pom</type>
80+
<scope>test</scope>
81+
</dependency>
6882
<dependency>
6983
<groupId>com.jayway.awaitility</groupId>
7084
<artifactId>awaitility</artifactId>
@@ -85,6 +99,37 @@
8599
<scope>test</scope>
86100
</dependency>
87101

102+
<dependency>
103+
<groupId>com.sun.faces</groupId>
104+
<artifactId>jsf-api</artifactId>
105+
<version>2.2.14</version>
106+
</dependency>
107+
<dependency>
108+
<groupId>com.sun.faces</groupId>
109+
<artifactId>jsf-impl</artifactId>
110+
<version>2.2.14</version>
111+
</dependency>
112+
<dependency>
113+
<groupId>javax.servlet</groupId>
114+
<artifactId>jstl</artifactId>
115+
<version>1.2</version>
116+
</dependency>
117+
<dependency>
118+
<groupId>javax.servlet</groupId>
119+
<artifactId>javax.servlet-api</artifactId>
120+
<version>3.1.0</version>
121+
</dependency>
122+
<dependency>
123+
<groupId>javax.servlet.jsp</groupId>
124+
<artifactId>jsp-api</artifactId>
125+
<version>2.2</version>
126+
<scope>provided</scope>
127+
</dependency>
128+
<dependency>
129+
<groupId>taglibs</groupId>
130+
<artifactId>standard</artifactId>
131+
<version>1.1.2</version>
132+
</dependency>
88133
</dependencies>
89134

90135
<build>
@@ -167,6 +212,7 @@
167212
</dependency>
168213
</dependencies>
169214
<build>
215+
<pluginManagement>
170216
<plugins>
171217
<plugin>
172218
<artifactId>maven-dependency-plugin</artifactId>
@@ -206,6 +252,7 @@
206252
</configuration>
207253
</plugin>
208254
</plugins>
255+
</pluginManagement>
209256
</build>
210257
</profile>
211258
<profile>
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package com.baeldung.convListVal;
2+
3+
import java.util.Date;
4+
5+
import javax.faces.bean.ManagedBean;
6+
7+
@ManagedBean
8+
public class ConvListVal {
9+
10+
private Integer age;
11+
private Double average;
12+
private Date myDate;
13+
private String name;
14+
private String surname;
15+
16+
public Integer getAge() {
17+
return age;
18+
}
19+
20+
public void setAge(Integer age) {
21+
this.age = age;
22+
}
23+
24+
public Double getAverage() {
25+
return average;
26+
}
27+
28+
public void setAverage(Double average) {
29+
this.average = average;
30+
}
31+
32+
public Date getMyDate() {
33+
return myDate;
34+
}
35+
36+
public void setMyDate(Date myDate) {
37+
this.myDate = myDate;
38+
}
39+
40+
public String getName() {
41+
return name;
42+
}
43+
44+
public void setName(String name) {
45+
this.name = name;
46+
}
47+
48+
public String getSurname() {
49+
return surname;
50+
}
51+
52+
public void setSurname(String surname) {
53+
this.surname = surname;
54+
}
55+
56+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.baeldung.convListVal;
2+
3+
import java.util.logging.Level;
4+
import java.util.logging.Logger;
5+
6+
import javax.faces.event.AbortProcessingException;
7+
import javax.faces.event.ValueChangeEvent;
8+
import javax.faces.event.ValueChangeListener;
9+
10+
public class MyListener implements ValueChangeListener {
11+
12+
private static final Logger LOG = Logger.getLogger(MyListener.class.getName());
13+
@Override
14+
public void processValueChange(ValueChangeEvent event) throws AbortProcessingException {
15+
if (event.getNewValue() != null) {
16+
LOG.log(Level.INFO, "\tNew Value:{0}", event.getNewValue());
17+
}
18+
19+
}
20+
21+
}

‎jee7/src/main/java/com/baeldung/javaeeannotations/JavaEEAnnotationsSample/src/main/java/com/baeldung/javaeeannotations/AccountServlet.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.baeldung.javaeeannotations;
1+
package com.baeldung.javaeeannotations.JavaEEAnnotationsSample.src.main.java.com.baeldung.javaeeannotations;
22

33
import java.io.IOException;
44
import java.io.PrintWriter;

‎jee7/src/main/java/com/baeldung/javaeeannotations/JavaEEAnnotationsSample/src/main/java/com/baeldung/javaeeannotations/BankAppServletContextListener.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.baeldung.javaeeannotations;
1+
package com.baeldung.javaeeannotations.JavaEEAnnotationsSample.src.main.java.com.baeldung.javaeeannotations;
22

33
import javax.servlet.ServletContextEvent;
44
import javax.servlet.ServletContextListener;

‎jee7/src/main/java/com/baeldung/javaeeannotations/JavaEEAnnotationsSample/src/main/java/com/baeldung/javaeeannotations/LogInFilter.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.baeldung.javaeeannotations;
1+
package com.baeldung.javaeeannotations.JavaEEAnnotationsSample.src.main.java.com.baeldung.javaeeannotations;
22

33
import java.io.IOException;
44

‎jee7/src/main/java/com/baeldung/javaeeannotations/JavaEEAnnotationsSample/src/main/java/com/baeldung/javaeeannotations/UploadCustomerDocumentsServlet.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.baeldung.javaeeannotations;
1+
package com.baeldung.javaeeannotations.JavaEEAnnotationsSample.src.main.java.com.baeldung.javaeeannotations;
22

33
import java.io.IOException;
44
import java.io.PrintWriter;
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<!DOCTYPE html>
2+
<html xmlns="http://www.w3.org/1999/xhtml"
3+
xmlns:h="http://xmlns.jcp.org/jsf/html"
4+
xmlns:f="http://xmlns.jcp.org/jsf/core">
5+
6+
<h:head>
7+
<title>Converters, Listeners and Validators</title>
8+
</h:head>
9+
<h:body>
10+
<h1>Testing converters</h1>
11+
<h:form id="myform">
12+
<h:outputLabel value="Age:"/>
13+
<h:inputText id="age" value="#{convListVal.age}">
14+
<f:converter converterId="javax.faces.Integer" />
15+
</h:inputText>
16+
<h:message id="ageError" for="age" />
17+
<br/>
18+
<h:outputLabel value="Average:"/>
19+
<h:inputText id="average" value="#{convListVal.average}">
20+
<f:converter converterId="javax.faces.Double" />
21+
</h:inputText>
22+
<h:message for="average" />
23+
<br/>
24+
<h:outputLabel value="Date:"/>
25+
<h:inputText id="MyDate" value="#{convListVal.myDate}">
26+
<f:convertDateTime pattern="dd/MM/yyyy" />
27+
</h:inputText>
28+
<h:message for="MyDate" />
29+
<br/>
30+
<h:outputText value="#{convListVal.myDate}">
31+
<f:convertDateTime dateStyle="full" locale="en"/>
32+
</h:outputText>
33+
<br/>
34+
<h:outputLabel value="Name:"/>
35+
<h:inputText id="name" size="30" value="#{convListVal.name}">
36+
<f:valueChangeListener type="com.baeldung.convListVal.MyListener" />
37+
</h:inputText>
38+
<br/>
39+
<h:outputLabel value="surname" for="surname"/>
40+
<h:panelGroup>
41+
<h:inputText id="surname" value="#{convListVal.surname}">
42+
<f:validateLength minimum="5" maximum="10"/>
43+
</h:inputText>
44+
<h:message for="surname" errorStyle="color:red" />
45+
</h:panelGroup>
46+
<br/>
47+
<h:commandButton id="send" value="submit" type="submit" />
48+
</h:form>
49+
</h:body>
50+
</html>

‎jee7/src/test/java/com/baeldung/jaxws/EmployeeServiceLiveTest.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.baeldung.jaxws;
1+
/*package com.baeldung.jaxws;
22
33
import static org.junit.Assert.assertEquals;
44
@@ -108,3 +108,4 @@ public void givenEmployee_whenDeleteNonExistingEmployee_thenEmployeeNotFoundExce
108108
}
109109
110110
}
111+
*/

0 commit comments

Comments
 (0)