Skip to content

Commit 155b405

Browse files
committed
commit project files
1 parent b428cd2 commit 155b405

File tree

62 files changed

+5326
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+5326
-0
lines changed

.gitignore

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.classpath
2+
.project
3+
.settings
4+
target/
5+
bin/
6+
7+
.idea/
8+
*.iml
9+
*.iws

demo/spring-jsr303-jsr303js/pom.xml

+114
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>fr.ippon.jsv.demo</groupId>
5+
<artifactId>spring-jsr303-jsr303js</artifactId>
6+
<packaging>war</packaging>
7+
<version>1.0-SNAPSHOT</version>
8+
<name>Demo SpringMVC + jsr303js</name>
9+
10+
<dependencies>
11+
<dependency>
12+
<groupId>org.springframework</groupId>
13+
<artifactId>spring-core</artifactId>
14+
<version>3.2.4.RELEASE</version>
15+
</dependency>
16+
17+
<dependency>
18+
<groupId>org.springframework</groupId>
19+
<artifactId>spring-context</artifactId>
20+
<version>3.2.4.RELEASE</version>
21+
</dependency>
22+
23+
<dependency>
24+
<groupId>org.springframework</groupId>
25+
<artifactId>spring-orm</artifactId>
26+
<version>3.2.4.RELEASE</version>
27+
</dependency>
28+
29+
<dependency>
30+
<groupId>org.springframework</groupId>
31+
<artifactId>spring-webmvc</artifactId>
32+
<version>3.2.4.RELEASE</version>
33+
</dependency>
34+
35+
<dependency>
36+
<groupId>jstl</groupId>
37+
<artifactId>jstl</artifactId>
38+
<version>1.2</version>
39+
</dependency>
40+
41+
<dependency>
42+
<groupId>org.apache.tiles</groupId>
43+
<artifactId>tiles-api</artifactId>
44+
<version>3.0.1</version>
45+
</dependency>
46+
47+
<dependency>
48+
<groupId>org.apache.tiles</groupId>
49+
<artifactId>tiles-core</artifactId>
50+
<version>3.0.1</version>
51+
</dependency>
52+
53+
<dependency>
54+
<groupId>org.apache.tiles</groupId>
55+
<artifactId>tiles-jsp</artifactId>
56+
<version>3.0.1</version>
57+
</dependency>
58+
59+
<dependency>
60+
<groupId>org.slf4j</groupId>
61+
<artifactId>slf4j-log4j12</artifactId>
62+
<version>1.5.8</version>
63+
</dependency>
64+
65+
<dependency>
66+
<groupId>org.hibernate</groupId>
67+
<artifactId>hibernate-validator</artifactId>
68+
<version>4.2.0.Final</version>
69+
</dependency>
70+
71+
<!--
72+
You need to install (mvn install) the real jsr303js jar first
73+
It can be found at this location : https://kenai.com/projects/jsr303js/pages/Home
74+
-->
75+
<dependency>
76+
<groupId>org.lanark</groupId>
77+
<artifactId>jsr303js</artifactId>
78+
<version>1.0-SNAPSHOT</version>
79+
</dependency>
80+
</dependencies>
81+
82+
<build>
83+
<finalName>jsr303js-ext</finalName>
84+
<plugins>
85+
<plugin>
86+
<groupId>org.apache.tomcat.maven</groupId>
87+
<artifactId>tomcat7-maven-plugin</artifactId>
88+
<configuration>
89+
<path>/${project.build.finalName}</path>
90+
<port>8080</port>
91+
<charset>UTF-8</charset>
92+
<finalName>${project.build.finalName}</finalName>
93+
<server>localserver</server>
94+
</configuration>
95+
</plugin>
96+
<plugin>
97+
<artifactId>maven-compiler-plugin</artifactId>
98+
<configuration>
99+
<source>1.6</source>
100+
<target>1.6</target>
101+
</configuration>
102+
</plugin>
103+
</plugins>
104+
<pluginManagement>
105+
<plugins>
106+
<plugin>
107+
<groupId>org.apache.tomcat.maven</groupId>
108+
<artifactId>tomcat7-maven-plugin</artifactId>
109+
<version>2.1</version>
110+
</plugin>
111+
</plugins>
112+
</pluginManagement>
113+
</build>
114+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package fr.ippon.blog.controllers;
2+
3+
import org.springframework.stereotype.Controller;
4+
import org.springframework.web.bind.annotation.ModelAttribute;
5+
import org.springframework.web.bind.annotation.RequestMapping;
6+
import org.springframework.web.bind.annotation.RequestMethod;
7+
8+
import fr.ippon.blog.model.FormBean;
9+
10+
@Controller
11+
@RequestMapping("/")
12+
/**
13+
* This class handles client requests
14+
*
15+
16+
*/
17+
public class ViewController {
18+
19+
public static final String VIEW_FORM = "form";
20+
public static final String VIEW_RESULT = "result";
21+
22+
@ModelAttribute("formBean")
23+
public FormBean getFormBean() {
24+
return new FormBean();
25+
}
26+
27+
@RequestMapping(method = RequestMethod.GET)
28+
public String renderForm() {
29+
return VIEW_FORM;
30+
}
31+
32+
@RequestMapping(value="/send", method = RequestMethod.POST)
33+
public String renderResult(@ModelAttribute FormBean formBean) {
34+
return VIEW_RESULT;
35+
}
36+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package fr.ippon.blog.model;
2+
3+
import javax.validation.constraints.Max;
4+
import javax.validation.constraints.Min;
5+
import javax.validation.constraints.NotNull;
6+
7+
/**
8+
* This class represents the HTML form
9+
*
10+
11+
*/
12+
public class FormBean {
13+
14+
@NotNull (message="Le prénom ne doit pas être vide")
15+
private String firstname;
16+
@NotNull (message="Le nom ne doit pas être vide")
17+
private String lastname;
18+
@Min(value=1, message="L'àge minimum autorisé est 1 an")
19+
@Max(value=125, message="L'àge maximal autorisé est 125 ans")
20+
private long age;
21+
22+
public String getFirstname() {
23+
return firstname;
24+
}
25+
public void setFirstname(String firstname) {
26+
this.firstname = firstname;
27+
}
28+
public String getLastname() {
29+
return lastname;
30+
}
31+
public void setLastname(String lastname) {
32+
this.lastname = lastname;
33+
}
34+
public long getAge() {
35+
return age;
36+
}
37+
public void setAge(long age) {
38+
this.age = age;
39+
}
40+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Form page
2+
firstname.label=Pr\u00e9nom
3+
lastname.label=Nom
4+
age.label=Age
5+
send=Envoyer
6+
7+
# Result page
8+
welcome.message=Bonjour {0} {1}, {2} ans
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<beans xmlns="http://www.springframework.org/schema/beans"
2+
xmlns:context="http://www.springframework.org/schema/context"
3+
xmlns:mvc="http://www.springframework.org/schema/mvc"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="
6+
http://www.springframework.org/schema/beans
7+
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
8+
http://www.springframework.org/schema/context
9+
http://www.springframework.org/schema/context/spring-context-3.0.xsd
10+
http://www.springframework.org/schema/mvc
11+
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
12+
13+
<context:component-scan base-package="fr.ippon.blog.controllers" />
14+
15+
<!-- support JSR303 annotation if JSR 303 validation present on classpath -->
16+
<mvc:annotation-driven />
17+
18+
<bean id="messageSource"
19+
class="org.springframework.context.support.ResourceBundleMessageSource">
20+
<property name="basenames">
21+
<list>
22+
<value>content/messages</value>
23+
</list>
24+
</property>
25+
</bean>
26+
27+
<bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
28+
<property name="viewClass" value="org.springframework.web.servlet.view.tiles3.TilesView" />
29+
</bean>
30+
31+
<bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles3.TilesConfigurer">
32+
<property name="definitions">
33+
<list>
34+
<value>/WEB-INF/tiles.xml</value>
35+
</list>
36+
</property>
37+
</bean>
38+
39+
</beans>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
2+
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
3+
4+
<%@ taglib uri="http://kenai.com/projects/jsr303js/" prefix="jsr303js"%>
5+
6+
<form:form commandName="formBean" method="POST"
7+
cssClass="uni-form" servletRelativeAction="/send">
8+
<div class="ctrl-holder">
9+
<form:label path="firstname">
10+
<spring:message code="firstname.label" />
11+
</form:label>
12+
<form:input path="firstname" />
13+
<span id="firstname_error" class="error"></span>
14+
</div>
15+
16+
<div class="ctrl-holder">
17+
<form:label path="lastname">
18+
<spring:message code="lastname.label" />
19+
</form:label>
20+
<form:input path="lastname" />
21+
<span id="lastname_error" class="error"></span>
22+
</div>
23+
24+
<div class="ctrl-holder">
25+
<form:label path="age">
26+
<spring:message code="age.label" />
27+
</form:label>
28+
<form:input path="age" />
29+
<span id="age_error" class="error"></span>
30+
</div>
31+
32+
<div class="ctrl-holder">
33+
<input type="submit" value="<spring:message code="send" />" ></input>
34+
</div>
35+
</form:form>
36+
37+
<jsr303js:codebase />
38+
<jsr303js:validate commandName="formBean"/>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
2+
3+
<html>
4+
<head>
5+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
6+
<title><tiles:insertAttribute name="title" ignore="true" /></title>
7+
<link rel="stylesheet" type="text/css" href="css/demo.css">
8+
</head>
9+
<body>
10+
<tiles:insertAttribute name="body" />
11+
</body>
12+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
2+
3+
<spring:message code="welcome.message"
4+
arguments="${formBean.firstname}, ${formBean.lastname}, ${formBean.age}" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<!DOCTYPE tiles-definitions PUBLIC
3+
"-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN"
4+
"http://tiles.apache.org/dtds/tiles-config_2_0.dtd">
5+
6+
<tiles-definitions>
7+
<definition name="base.definition" template="/WEB-INF/html/layout.jsp">
8+
<put-attribute name="title" value="" />
9+
</definition>
10+
11+
<definition name="form" extends="base.definition">
12+
<put-attribute name="title" value="Informations utilisateur" />
13+
<put-attribute name="body" value="/WEB-INF/html/form.jsp" />
14+
</definition>
15+
16+
<definition name="result" extends="base.definition">
17+
<put-attribute name="title" value="Résultat" />
18+
<put-attribute name="body" value="/WEB-INF/html/result.jsp" />
19+
</definition>
20+
</tiles-definitions>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
4+
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
5+
version="2.5">
6+
7+
<display-name>JSR303JS - Ext</display-name>
8+
9+
<servlet>
10+
<servlet-name>mvc-dispatcher</servlet-name>
11+
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
12+
<init-param>
13+
<param-name>contextConfigLocation</param-name>
14+
<param-value>/WEB-INF/applicationContext.xml</param-value>
15+
</init-param>
16+
<load-on-startup>1</load-on-startup>
17+
</servlet>
18+
19+
<servlet-mapping>
20+
<servlet-name>mvc-dispatcher</servlet-name>
21+
<url-pattern>/</url-pattern>
22+
</servlet-mapping>
23+
24+
<!-- Prevents CSS to be caught in Spring mapping -->
25+
<servlet-mapping>
26+
<servlet-name>default</servlet-name>
27+
<url-pattern>*.css</url-pattern>
28+
</servlet-mapping>
29+
30+
<!-- Prevents JS to be caught in Spring mapping -->
31+
<servlet-mapping>
32+
<servlet-name>default</servlet-name>
33+
<url-pattern>*.js</url-pattern>
34+
</servlet-mapping>
35+
36+
<listener>
37+
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
38+
</listener>
39+
</web-app>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.ctrl-holder label {
2+
width: 100px;
3+
display: inline-block;
4+
}
5+
6+
.error {
7+
color: red;
8+
}

0 commit comments

Comments
 (0)