Welcome to the Core JSF (First Edition) FAQ!

Book cover

Question: Is the book compatible with JSF 1.1?

Answer:Yes. JSF 1.1 is a maintenance release that has only minor bug fixes. (A version number 1.0a or 1.01 would have been more descriptive.)  None of the issues that are addressed in the maintenance release have any impact on the book. 

Question: Why do I get errors when using the book's build instructions with Tomcat 5.5.x?

Answer: Unlike Tomcat 5.0.x, Tomcat 5.5.x doesn't have the commons-digester.jar and commons-beanutils.jar in the tomcat/server/lib directory. Instead, these files need to be obtained from jsf/lib.

In step 4 of the instructions on page 11, change

tomcat/server/lib/commons-digester.jar
tomcat/server/lib/commons-beanutils.jar

to

jsf/lib/commons-digester.jar
jsf/lib/commons-beanutils.jar
jsf/lib/commons-collections.jar

In the build.properties file on page 32, change line 13 to

commons.lib.dir=${jsf.dir}/lib

and line 17 to

commons.libs=commons-beanutils.jar,commons-digester.jar,commons-collections.jar

Question: Can I use MyFaces with the examples in the book?

Answer: Yes.

  1. Use Ant, as described on page 30, with this build.properties file. Change the version numbers to match your installation
    jsf.dir=/usr/local/myfaces-1.0.9
    tomcat.dir=/usr/local/jakarta-tomcat-5.5.7

    username=me
    password=secret
    manager.url=http://localhost:8080/manager

    servlet.api.jar=${tomcat.dir}/common/lib/servlet-api.jar
    jsp.api.jar=${tomcat.dir}/common/lib/jsp-api.jar

    jsf.lib.dir=${jsf.dir}/lib
    jstl.lib.dir=${tomcat.dir}/webapps/jsp-examples/WEB-INF/lib
    commons.lib.dir=${jsf.dir}/lib

    jsf.libs=myfaces.jar
    jstl.libs=jstl.jar,standard.jar
    commons.libs=commons-beanutils-1.6.1.jar,commons-digester-1.5.jar,commons-collections-3.0.jar
  2. Add the following entry at the end of each web.xml file, just before the </web-app>tag:
    <listener>
    <listener-class>
    org.apache.myfaces.webapp.StartupServletContextListener
    </listener-class>
    </listener>

Question: Why doesn't the tiles example work?

Answer: Starting with Struts 1.2, you cannot use Tiles standalone. Download Struts 1.1 from http://www.apache.org/dist/jakarta/struts/binaries and follow the directions on installing Tiles on page 331.

Question: Why do I get an error message "package javax.servlet.jsp.jstl.sql does not exist"?

Answer: Be sure to include the JSTL library in your class path. You need the JAR file tomcat/webapps/jsp-examples/WEB-INF/lib/jstl.jar.

Question: Why doesn't the XML format described on page 15 work with Internet Explorer?

Answer: Are you finding XHTML problems with Internet Explorer? We are shocked--shocked--to find out that this fine browser has problems.

The remedy is to lie about the MIME type. Add a statement

<jsp:directive.page contentType="text/html"/>

Question: Why doesn't the deletingRows example in chapter 5 work with Internet Explorer?

Answer: We are shocked--shocked--to find out that this fine browser has problems.

Unfortunately, the browser doesn't refresh as a result of the onchange=submit() JavaScript command. Here is Marty Hall's advice on this issue:

"The problem is that Internet Explorer fires onchange events only when the entry has changed AND another element has gotten the input focus. So, with checkboxes and IE, you would have to check/uncheck the checkbox AND click on some other random entry. I tried it, and the IE behavior was so odd that there was virtually no hope that real users could understand it.

The original motivation for this onchange behavior was for textfields, where you didn't want to say the value was wrong until they finished typing it in. Anyhow, in most recent versions of IE, Netscape, and Opera, you can use onclick instead. Even if you use onclick, though, you might have problems with older browsers. Using both onclick and onchange can cause problems as well, so I have not found a foolproof way to handle value change events across many different browser versions. But most users have relatively recent IE versions, so onclick (NOT onchange) will work. "

Change lines 22 and 40 of ch5/deletingRows/index.jsp from onchange to onclick, and the example will work with IE.

Question: How can I use JavaScript together with navigation?

Answer: The example on page 100 simply refreshes the current page. If you want to use navigation, you cannot use a commandButton with type="button". Instead, use a regular button such as

<h:commandButton value="Submit Form" action="login"/>

Attach the JavaScript code to the form, like this:

      <h:form id="registerForm" onsubmit="return checkPassword()">
      . . . <script type="text/javascript">
      <!--
         function checkPassword() {
            var form = document.forms["registerForm"];
            var password = form["registerForm:password"].value;
            var passwordConfirm = form["registerForm:passwordConfirm"].value;

            if (password == passwordConfirm)
               return true;
            else {          
               alert("Password and password confirm fields don't match");
               return false;
            }
         }
      -->
      </script>

Question: Why do I get an Ant error Unexpected element "basename"?

Answer: Please use Ant version 1.6 or later.

Question: How can I get an electronic copy of the book?

Answer: Please go to the Safari site and search for (AUTHOR Geary) AND (AUTHOR Horstmann)