0

I've created a netbeans (7.31) new web project with JSF 2.2, using Tomcat, and I downloaded and added Bootsfaces-OSP-dist-0.7.jar to my project. I did all things related in Bootsfaces quick start guide, included all about web.xml , faces-config.xml and theme css support. I did not nothing about maven pom.xml build file (Working with netbeans IDE i didn't need to do nothing in pom.xml, and I dont know how to do in a project with netbeans IDE) I also created a index.xhtml page like related in quick start guide (with <h:head/> tags ) When I run my project all looks without any styling.

Can anybody help me with a guide step by step to do bootsfaces work in a project created with netbeans IDE, JSF 2.2 and tomcat ?

Here is my web.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
    <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Development</param-value>
    </context-param>
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>/faces/*</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.jsf</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.faces</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.xhtml</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>/javax.faces.resource/*</url-pattern>
    </servlet-mapping>

    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
    <welcome-file-list>
        <welcome-file>faces/index.xhtml</welcome-file>
    </welcome-file-list>
    <context-param>
        <param-name>BootsFaces_USETHEME</param-name>
        <param-value>true</param-value>
    </context-param>
</web-app>

`

Jose A. Gam
  • 3
  • 1
  • 3
  • What URL pattern is `FacesServlet` listening on according to your `web.xml`? What URL is shown in browser's address bar when you tried to open the page? – BalusC Jun 25 '15 at 11:03
  • I added my web.xml file to my question, and the URL looks: http://localhost:8080/TestBootsfaces1/ – Jose A. Gam Jun 25 '15 at 11:51
  • The 5 mappings and the welcome file entry are definitely awkward. Where exactly did you learn about that? Why exactly is it configured like that? Or is this all Netbeans-generated and/or based on some random example project? In any case, if you do rightclick, *View Source* in webbrowser, do you see JSF-generated HTML output, or do you see the unparsed raw XHTML source? – BalusC Jun 25 '15 at 12:07
  • About 5 mappings I pasted it into web.xml file after read the help of sombody in some google search, and about welcome file entry is auto-generated when create a new web project in Netbeans. When rightclick i see Html output. – Jose A. Gam Jun 25 '15 at 12:45
  • Boil down all those mappings to just only one mapping on `*.xhtml` and fix welcome file to get rid of `faces/` folder altogether. The welcome file doesn't represent the home page. It represents the file name of the directory's index file. Now retry and if it still fails, tell what you observed in the HTTP payload in browser's HTTP traffic monitor. – BalusC Jun 25 '15 at 12:50
  • Still fails. Using httpwatch, there are some GET with 404 error: GET 404 html http://localhost:8080/TestBootsfaces1/javax.faces.resource/css/core.css, GET 404 html http://localhost:8080/TestBootsfaces1/javax.faces.resource/css/navbar.css, GET 404 html http://localhost:8080/TestBootsfaces1/javax.faces.resource/js/tooltip.js, etc. – Jose A. Gam Jun 25 '15 at 18:03

2 Answers2

0

Well, everything works fine for me. I did the following steps:

  1. I created a new Web Project in Netbeans 8.0.2 and added JSF 2.2 (Library, then Add Library).
  2. Downloaded the newest Bootsfaces JAR from their site and added it the Project (Library, then Add JAR/Folder).
  3. Created a new JSF file:

    <?xml version='1.0' encoding='UTF-8' ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:b="http://bootsfaces.net/ui"
      xmlns:h="http://xmlns.jcp.org/jsf/html">
    <h:head>
        <title>Facelet Title</title>
    </h:head>
    <h:body>
        <b:navBar brand="Brand" brandHref="#" inverse="true">
            <b:navbarLinks>
            <b:navLink value="Home" href="#"></b:navLink>
            <b:navLink value="Link" href="#"></b:navLink>
            <b:navLink value="Link" href="#"></b:navLink>
            </b:navbarLinks>
        </b:navBar>
    </h:body>
    

Just don't forget about this part xmlns:b="http://bootsfaces.net/ui".

mmalik
  • 185
  • 2
  • 11
  • I did that in netbeans 8.02: new web project + server: Apache Tomcat, Java EE 6 Web + Frameworks: JavaServer Faces, Registered Libraries:JSF 2.2. After I added Bootsfaces-OSP-dist-0.7.jar to my project. In index.xhtml autogenerated, I paste what you say in point 3, including xmlns:b="http://bootsfaces.net/ui". But doesn't work, Not style applyed when run – Jose A. Gam Jun 25 '15 at 10:15
0

There are at least three pitfalls which make your theme disappear:

  • Did you add the theme to the web.xml? xml <context-param> <param-name>BootsFaces_USETHEME</param-name> <param-value>true</param-value> </context-param>
  • Please don't use folder names in the servlet mapping. I'm not sure if it causes CSS error, but certainly it makes things more complex and might confuse the resource mapper.
  • For some reason, BootsFaces works better if you add the CombinedResourceHandler of OmniFaces to the faces-config.xml. Alternatively, you can add the UnmappedResourceHandler (which is part of BootsFaces). More often than not, BootsFaces needs one of those to find the CSS files and / or the font. Also see http://www.bootsfaces.net/integration/OmniFaces.jsf.

Another approach that usually works is to start with one the the demo projects, such as https://github.com/stephanrauh/BootsFaces-Examples.

Stephan Rauh
  • 3,069
  • 2
  • 18
  • 37
  • Thanks for your response. It works fine with BootsFaces-Examples, but these are maven proyects. My problem is when I create Web projects with Netbeans IDE without maven: Netbeans + New Project + Java Web + Web Application + Server: Tomcat + Framework: JavaServer Faces. I'm used to working without maven , it is easier for me and I would like it to work without maven. – Jose A. Gam Jun 30 '15 at 09:57
  • The idea was to give you a running example. You don't have to migrate to Maven. Just examine the project layout of the running example and use it as a template for your Netbeans project. In theory, only the folders should differ. – Stephan Rauh Jul 01 '15 at 11:17