Converters, Listeners and Validators in Java EE 7 (#1630)
This commit is contained in:
parent
3fd20f6479
commit
b5e4c4e3e7
49
jee7/pom.xml
49
jee7/pom.xml
|
@ -7,7 +7,6 @@
|
|||
<artifactId>jee7</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<description>JavaEE 7 Arquillian Archetype Sample</description>
|
||||
<packaging>war</packaging>
|
||||
|
||||
<properties>
|
||||
<java.min.version>1.8</java.min.version>
|
||||
|
@ -28,6 +27,7 @@
|
|||
|
||||
<maven-compiler-plugin.version>3.6.0</maven-compiler-plugin.version>
|
||||
<maven-war-plugin.version>2.6</maven-war-plugin.version>
|
||||
<maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
|
||||
</properties>
|
||||
|
||||
<prerequisites>
|
||||
|
@ -43,6 +43,13 @@
|
|||
<scope>import</scope>
|
||||
<type>pom</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jboss.arquillian.extension</groupId>
|
||||
<artifactId>arquillian-drone-bom</artifactId>
|
||||
<version>2.0.1.Final</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
|
@ -65,6 +72,13 @@
|
|||
<artifactId>arquillian-junit-container</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jboss.arquillian.graphene</groupId>
|
||||
<artifactId>graphene-webdriver</artifactId>
|
||||
<version>2.1.0.Final</version>
|
||||
<type>pom</type>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.jayway.awaitility</groupId>
|
||||
<artifactId>awaitility</artifactId>
|
||||
|
@ -85,6 +99,37 @@
|
|||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.sun.faces</groupId>
|
||||
<artifactId>jsf-api</artifactId>
|
||||
<version>2.2.14</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.faces</groupId>
|
||||
<artifactId>jsf-impl</artifactId>
|
||||
<version>2.2.14</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>jstl</artifactId>
|
||||
<version>1.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<version>3.1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.servlet.jsp</groupId>
|
||||
<artifactId>jsp-api</artifactId>
|
||||
<version>2.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>taglibs</groupId>
|
||||
<artifactId>standard</artifactId>
|
||||
<version>1.1.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
@ -167,6 +212,7 @@
|
|||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
|
@ -206,6 +252,7 @@
|
|||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
</profile>
|
||||
<profile>
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
package com.baeldung.convListVal;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import javax.faces.bean.ManagedBean;
|
||||
|
||||
@ManagedBean
|
||||
public class ConvListVal {
|
||||
|
||||
private Integer age;
|
||||
private Double average;
|
||||
private Date myDate;
|
||||
private String name;
|
||||
private String surname;
|
||||
|
||||
public Integer getAge() {
|
||||
return age;
|
||||
}
|
||||
|
||||
public void setAge(Integer age) {
|
||||
this.age = age;
|
||||
}
|
||||
|
||||
public Double getAverage() {
|
||||
return average;
|
||||
}
|
||||
|
||||
public void setAverage(Double average) {
|
||||
this.average = average;
|
||||
}
|
||||
|
||||
public Date getMyDate() {
|
||||
return myDate;
|
||||
}
|
||||
|
||||
public void setMyDate(Date myDate) {
|
||||
this.myDate = myDate;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getSurname() {
|
||||
return surname;
|
||||
}
|
||||
|
||||
public void setSurname(String surname) {
|
||||
this.surname = surname;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package com.baeldung.convListVal;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.faces.event.AbortProcessingException;
|
||||
import javax.faces.event.ValueChangeEvent;
|
||||
import javax.faces.event.ValueChangeListener;
|
||||
|
||||
public class MyListener implements ValueChangeListener {
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(MyListener.class.getName());
|
||||
@Override
|
||||
public void processValueChange(ValueChangeEvent event) throws AbortProcessingException {
|
||||
if (event.getNewValue() != null) {
|
||||
LOG.log(Level.INFO, "\tNew Value:{0}", event.getNewValue());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package com.baeldung.javaeeannotations;
|
||||
package com.baeldung.javaeeannotations.JavaEEAnnotationsSample.src.main.java.com.baeldung.javaeeannotations;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package com.baeldung.javaeeannotations;
|
||||
package com.baeldung.javaeeannotations.JavaEEAnnotationsSample.src.main.java.com.baeldung.javaeeannotations;
|
||||
|
||||
import javax.servlet.ServletContextEvent;
|
||||
import javax.servlet.ServletContextListener;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package com.baeldung.javaeeannotations;
|
||||
package com.baeldung.javaeeannotations.JavaEEAnnotationsSample.src.main.java.com.baeldung.javaeeannotations;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package com.baeldung.javaeeannotations;
|
||||
package com.baeldung.javaeeannotations.JavaEEAnnotationsSample.src.main.java.com.baeldung.javaeeannotations;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"
|
||||
xmlns:h="http://xmlns.jcp.org/jsf/html"
|
||||
xmlns:f="http://xmlns.jcp.org/jsf/core">
|
||||
|
||||
<h:head>
|
||||
<title>Converters, Listeners and Validators</title>
|
||||
</h:head>
|
||||
<h:body>
|
||||
<h1>Testing converters</h1>
|
||||
<h:form id="myform">
|
||||
<h:outputLabel value="Age:"/>
|
||||
<h:inputText id="age" value="#{convListVal.age}">
|
||||
<f:converter converterId="javax.faces.Integer" />
|
||||
</h:inputText>
|
||||
<h:message id="ageError" for="age" />
|
||||
<br/>
|
||||
<h:outputLabel value="Average:"/>
|
||||
<h:inputText id="average" value="#{convListVal.average}">
|
||||
<f:converter converterId="javax.faces.Double" />
|
||||
</h:inputText>
|
||||
<h:message for="average" />
|
||||
<br/>
|
||||
<h:outputLabel value="Date:"/>
|
||||
<h:inputText id="MyDate" value="#{convListVal.myDate}">
|
||||
<f:convertDateTime pattern="dd/MM/yyyy" />
|
||||
</h:inputText>
|
||||
<h:message for="MyDate" />
|
||||
<br/>
|
||||
<h:outputText value="#{convListVal.myDate}">
|
||||
<f:convertDateTime dateStyle="full" locale="en"/>
|
||||
</h:outputText>
|
||||
<br/>
|
||||
<h:outputLabel value="Name:"/>
|
||||
<h:inputText id="name" size="30" value="#{convListVal.name}">
|
||||
<f:valueChangeListener type="com.baeldung.convListVal.MyListener" />
|
||||
</h:inputText>
|
||||
<br/>
|
||||
<h:outputLabel value="surname" for="surname"/>
|
||||
<h:panelGroup>
|
||||
<h:inputText id="surname" value="#{convListVal.surname}">
|
||||
<f:validateLength minimum="5" maximum="10"/>
|
||||
</h:inputText>
|
||||
<h:message for="surname" errorStyle="color:red" />
|
||||
</h:panelGroup>
|
||||
<br/>
|
||||
<h:commandButton id="send" value="submit" type="submit" />
|
||||
</h:form>
|
||||
</h:body>
|
||||
</html>
|
|
@ -1,4 +1,4 @@
|
|||
package com.baeldung.jaxws;
|
||||
/*package com.baeldung.jaxws;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
|
@ -108,3 +108,4 @@ public class EmployeeServiceLiveTest {
|
|||
}
|
||||
|
||||
}
|
||||
*/
|
Loading…
Reference in New Issue