Maven + JSF + Bootstrap example!

Lets see!

Directory Layout:

pom.xml
<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/maven-v4_0_0.xsd">
 
    <modelVersion>4.0.0</modelVersion>
 
    <groupId>biz.tugay</groupId>
    <artifactId>jsfbootstrap</artifactId>
    <packaging>war</packaging>
 
    <version>1.0-SNAPSHOT</version>
 
    <name>jsfbootstrap Maven Webapp</name>
    <url>http://www.tugay.biz</url>
 
    <dependencies>
        <dependency>
            <groupId>javax.faces</groupId>
            <artifactId>javax.faces-api</artifactId>
            <version>2.2</version>
        </dependency>
        <dependency>
            <groupId>com.sun.faces</groupId>
            <artifactId>jsf-impl</artifactId>
            <version>2.2.13</version>
        </dependency>
        <dependency>
            <groupId>javax.el</groupId>
            <artifactId>javax.el-api</artifactId>
            <version>3.0.0</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
 
    <build>
        <finalName>jsfbootstrap</finalName>
        <plugins>
            <plugin>
                <groupId>org.eclipse.jetty</groupId>
                <artifactId>jetty-maven-plugin</artifactId>
                <version>9.2.1.v20140609</version>
                <configuration>
                    <scanIntervalSeconds>2</scanIntervalSeconds>
                    <webApp>
                        <contextPath>/</contextPath>
                    </webApp>
                </configuration>
            </plugin>
        </plugins>
    </build>
 
</project>

web.xml
<web-app 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-app_3_1.xsd"
         version="3.1">
 
    <servlet>
        <servlet-name>FacesServlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    </servlet>
 
    <servlet-mapping>
        <servlet-name>FacesServlet</servlet-name>
        <url-pattern>*.xhtml</url-pattern>
    </servlet-mapping>
 
    <context-param>
        <param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name>
        <param-value>true</param-value>
    </context-param>
 
    <welcome-file-list>
        <welcome-file>foo.xhtml</welcome-file>
    </welcome-file-list>
 
</web-app>

foo.xml
<!--
    User: Koray Tugay (koray@tugay.biz)
    Date: 7/22/2016
    Time: 7:58 PM
-->
 
<!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">
<f:view>
    <h:head>
        <title>Foo</title>
        <h:outputStylesheet library="css" name="bootstrap.css"/>
    </h:head>
    <h:body>
        <h:panelGroup layout="block"
                      styleClass="container">
            <h:panelGroup layout="block"
                          styleClass="hero-unit"
                          style="margin: 40px">
                <h2>Hello World, Twitter Bootstrap + JSF!</h2>
                <h:form id="fooForm"
                        prependId="false">
                    <h:inputText value="#{foo.foo}"/>
                    <br/>
                    <h:commandButton value="Submit" styleClass="btn btn-primary"/>
                </h:form>
                <h:outputText id="outputText"
                              styleClass="text-success"
                              value="#{foo.foo}"/>
            </h:panelGroup>
        </h:panelGroup>
        <h:outputScript library="js" name="jquery.js"/>
        <h:outputScript library="js" name="bootstrap.js"/>
    </h:body>
</f:view>
</html>

Looks nice, no?