Skip to content

Commit 110fa6a

Browse files
committed
Added sample for JSF 2.3 extensionless mapping
1 parent 9e8d7d7 commit 110fa6a

File tree

16 files changed

+278
-15
lines changed

16 files changed

+278
-15
lines changed

cdi/dynamic-bean/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion>
33

44
<parent>
5-
<groupId>org.javaee8.cdi</groupId>
6-
<artifactId>cdi-samples</artifactId>
5+
<groupId>org.javaee8</groupId>
6+
<artifactId>cdi</artifactId>
77
<version>1.0-SNAPSHOT</version>
88
</parent>
99

cdi/events-async/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion>
33

4-
<parent>
5-
<groupId>org.javaee8.cdi</groupId>
6-
<artifactId>cdi-samples</artifactId>
4+
<parent>
5+
<groupId>org.javaee8</groupId>
6+
<artifactId>cdi</artifactId>
77
<version>1.0-SNAPSHOT</version>
88
</parent>
99

cdi/events-priority/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion>
33

44
<parent>
5-
<groupId>org.javaee8.cdi</groupId>
6-
<artifactId>cdi-samples</artifactId>
5+
<groupId>org.javaee8</groupId>
6+
<artifactId>cdi</artifactId>
77
<version>1.0-SNAPSHOT</version>
88
</parent>
99

cdi/interception-factory/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion>
33

44
<parent>
5-
<groupId>org.javaee8.cdi</groupId>
6-
<artifactId>cdi-samples</artifactId>
5+
<groupId>org.javaee8</groupId>
6+
<artifactId>cdi</artifactId>
77
<version>1.0-SNAPSHOT</version>
88
</parent>
99

cdi/pom.xml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3-
<modelVersion>4.0.0</modelVersion>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion>
3+
44
<parent>
55
<groupId>org.javaee8</groupId>
66
<artifactId>samples-parent</artifactId>
77
<version>1.0-SNAPSHOT</version>
88
</parent>
99

10-
<groupId>org.javaee8.cdi</groupId>
11-
<artifactId>cdi-samples</artifactId>
10+
<artifactId>cdi</artifactId>
1211
<packaging>pom</packaging>
1312
<name>Java EE 8 Samples: CDI</name>
1413

jsf/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Java EE 8 Samples: JSF 2.3#
2+
3+
The [JSR 372](https://jcp.org/en/jsr/detail?id=372) specifies the next version of JavaServer Faces - JSF 2.3.
4+
5+
## Samples ##
6+
7+
- extensionless-mapping shows how to configure JSF so that views can be requested without using an extension
8+
9+
10+

jsf/extensionless-mapping/pom.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion>
3+
4+
<parent>
5+
<groupId>org.javaee8</groupId>
6+
<artifactId>jsf</artifactId>
7+
<version>1.0-SNAPSHOT</version>
8+
</parent>
9+
10+
<artifactId>extensionless-mapping</artifactId>
11+
<name>Java EE 8 Samples: JSF - Extensionless Mapping</name>
12+
13+
</project>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package org.javaee8.cdi.dynamic.bean;
2+
3+
import static javax.faces.annotation.FacesConfig.Version.JSF_2_3;
4+
5+
import javax.enterprise.context.ApplicationScoped;
6+
import javax.faces.annotation.FacesConfig;
7+
8+
/**
9+
* This class is needed to activate JSF and configure it to be the
10+
* right version. Without this being present an explicit mapping
11+
* of the FacesServlet in web.xml would be required, but JSF 2.3
12+
* would then run in a JSF 2.2 compatibility mode.
13+
*
14+
* @author Arjan Tijms
15+
*/
16+
@FacesConfig(version = JSF_2_3)
17+
@ApplicationScoped
18+
public class ApplicationInit {
19+
20+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package org.javaee8.cdi.dynamic.bean;
2+
3+
import static javax.faces.application.ViewVisitOption.RETURN_AS_MINIMAL_IMPLICIT_OUTCOME;
4+
5+
import javax.faces.context.FacesContext;
6+
import javax.faces.webapp.FacesServlet;
7+
import javax.servlet.ServletContextEvent;
8+
import javax.servlet.ServletContextListener;
9+
import javax.servlet.annotation.WebListener;
10+
11+
/**
12+
*
13+
* @author Arjan Tijms
14+
*/
15+
@WebListener
16+
public class MappingInit implements ServletContextListener {
17+
18+
@Override
19+
public void contextInitialized(ServletContextEvent sce) {
20+
FacesContext context = FacesContext.getCurrentInstance();
21+
22+
sce.getServletContext()
23+
.getServletRegistrations()
24+
.values()
25+
.stream()
26+
.filter(e -> e.getClassName().equals(FacesServlet.class.getName()))
27+
.findAny()
28+
.ifPresent(
29+
reg -> context.getApplication()
30+
.getViewHandler()
31+
.getViews(context, "/", RETURN_AS_MINIMAL_IMPLICIT_OUTCOME)
32+
.forEach(e -> reg.addMapping(e)));
33+
}
34+
35+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version='1.0' encoding='UTF-8' ?>
2+
<!DOCTYPE html>
3+
<html xmlns="http://www.w3.org/1999/xhtml"
4+
xmlns:h="http://xmlns.jcp.org/jsf/html"
5+
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
6+
xmlns:f="http://xmlns.jcp.org/jsf/core">
7+
8+
<h:head>
9+
<title>Bar page</title>
10+
</h:head>
11+
12+
<h:body>
13+
This is page bar
14+
</h:body>
15+
</html>
16+

0 commit comments

Comments
 (0)