JSF 1.2 + JBoss 5没有渲染jsf标签。

时间:2012-12-13 18:19:41

标签: java jsf richfaces jsf-1.2

我正在尝试将.net应用程序转换为JSF 1.2,以便在我们的旧JBoss服务器上进行转换,但我无法获取要呈现的jsf标记。在我的浏览器中,我看到了我在eclipse中看到的内容。

任何建议都表示赞赏。

的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>

1 个答案:

答案 0 :(得分:3)

根据评论,您在按照自己的docbook配置Facelets 1.x时会遇到以下异常:

  

找不到完全限定的类:com.sun.facelets.FaceletViewHandler

显然JBoss 5.x不提供Facelets 1.x开箱即用(可能非常好,因为它不是标准Java EE 5的一部分)。您需要在webapp /WEB-INF/lib中自行提供。您可以从Maven存储库中获取它here。这是jsf-facelets.jar文件。

请注意,JSF 2.x不需要此文件,因为Facelets库捆绑在JSF JAR本身中。