Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<jsf.version>2.2.14</jsf.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -58,6 +59,18 @@
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>

<!-- JSF dependencies-->
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>${jsf.version}</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>${jsf.version}</version>
</dependency>
</dependencies>

<build>
Expand Down
27 changes: 27 additions & 0 deletions src/main/java/eu/arima/JSFConfiguration.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package eu.arima;

import javax.faces.webapp.FacesServlet;

import org.springframework.boot.web.servlet.ServletListenerRegistrationBean;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.sun.faces.config.ConfigureListener;

@Configuration
public class JSFConfiguration {

@Bean
public ServletRegistrationBean facesServletRegistration() {
ServletRegistrationBean registration = new ServletRegistrationBean(new FacesServlet(), "*.xhtml");
registration.setName("FacesServlet");
registration.setLoadOnStartup(1);
return registration;
}

@Bean
public ServletListenerRegistrationBean<ConfigureListener> jsfConfigureListener() {
return new ServletListenerRegistrationBean<ConfigureListener>(new ConfigureListener());
}
}
30 changes: 30 additions & 0 deletions src/main/java/eu/arima/beans/JsfBean.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package eu.arima.beans;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Service;

@Service
public class JsfBean {

private String message;

private List<String> list;

public JsfBean() {
this.message = "Hello Arima!!!";
this.list = new ArrayList<>();
for (int i = 0; i < 10; i++) {
this.list.add("Message " + i);
}
}

public String getMensaje() {
return this.message;
}

public List<String> getList() {
return this.list;
}
}
5 changes: 5 additions & 0 deletions src/main/webapp/WEB-INF/faces-config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<faces-config xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd" version="2.2">
<application>
<el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
</application>
</faces-config>
13 changes: 13 additions & 0 deletions src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">

<servlet>
<servlet-name>FacesServlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
</servlet>

</web-app>
21 changes: 21 additions & 0 deletions src/main/webapp/jsf/hello.xhtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:c="http://java.sun.com/jsp/jstl/core">

<h:head>
<title>Login</title>
</h:head>
<h:body>

<h1>
<h:outputText value="#{jsfBean.mensaje}" />
</h1>

<c:forEach var="message" items="#{jsfBean.list}">
<h:outputText value="#{message}" />
<br/>
</c:forEach>

</h:body>

</html>