Search code examples
javajsfrichfacesjsf-1.2

JSF 1.2 + JBoss 5 not rendering jsf tags.


I'm trying to convert a .net app to JSF 1.2 to sit on our legacy JBoss server and I can't get the jsf tags to render. In my browser i see exactly what i see in eclipse.

Any suggestions are appreciated.

web.xml

<?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_2_5.xsd" 
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
         version="2.5">
  <display-name>WebDataViewer</display-name>

    <context-param>
        <param-name>javax.faces.FACELETS_LIBRARIES</param-name>
        <param-value>/WEB-INF/tlds/formatter-taglib.xml</param-value>
    </context-param>

    <!-- JSF -->
    <context-param>     
        <param-name>javax.faces.CONFIG_FILES</param-name>     
        <param-value>/WEB-INF/faces-config.xml</param-value>     
    </context-param> 

    <context-param>     
        <param-name>javax.faces.DEFAULT_SUFFIX</param-name>     
        <param-value>.xhtml</param-value>     
    </context-param> 

    <context-param>     
        <param-name>javax.faces.STATE_SAVING_METHOD</param-name>     
        <param-value>server</param-value>     
    </context-param>  

    <context-param>
        <param-name>facelets.VIEW_MAPPINGS</param-name>
        <param-value>*.xhtml</param-value>
    </context-param>

    <context-param>
        <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
        <param-value>com.sun.facelets.FaceletViewHandler</param-value>
    </context-param>

    <context-param>
        <param-name>org.richfaces.SKIN</param-name>
        <param-value>CLASSIC</param-value>
    </context-param>

    <listener>     
        <listener-class>com.sun.faces.config.ConfigureListener</listener-class>    
    </listener>    

    <!-- Allows you to put html comments in your views without the compiler blowing up -->
    <context-param>
        <param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name>
        <param-value>true</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>*.jsf</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>/faces/*</url-pattern>
    </servlet-mapping>

    <welcome-file-list>
        <welcome-file>index.xhtml</welcome-file>
    </welcome-file-list>
</web-app>

faces-config.xml

<?xml version="1.0" encoding="UTF-8"?>

<faces-config
    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-facesconfig_1_2.xsd"
    version="1.2">

    <application>
        <view-handler>org.ajax4jsf.application.AjaxViewHandler</view-handler>
    </application>

    <!-- Backing Beans -->  
    <managed-bean>
        <managed-bean-name>tableBacking</managed-bean-name>
        <managed-bean-class>edu.mayo.ccs.webdataviewer.ui.backing.TableLookupBacking</managed-bean-class>
        <managed-bean-scope>session</managed-bean-scope>
    </managed-bean>

</faces-config>

index.xhtml

<!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:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:rich="http://richfaces.org/rich"
    xmlns:a4j="http://richfaces.org/a4j" 
    xmlns:ui="http://java.sun.com/jsf/facelets">

    <ui:composition template="/template.xhtml">

        <ui:define name="title">Web Data Viewer</ui:define>

        <ui:define name="centerColumn">
            <h1>Web Data Viewer</h1>                                
        </ui:define>

    </ui:composition>
</html>

Solution

  • As per the comments, you're getting the following exception while configuring Facelets 1.x as per their own docbook:

    cannot find fully qualified class: com.sun.facelets.FaceletViewHandler

    Apparently JBoss 5.x doesn't ship with Facelets 1.x out the box (could be very good as it's not part of standard Java EE 5). You'd need to provide it yourself in webapp's /WEB-INF/lib. You can get it from the Maven repository among others here. It's the jsf-facelets.jar file.

    Note that this file is not required for JSF 2.x as Facelets libraries are bundled in the JSF JAR itself.