0

我正在尝试将 .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>

面孔-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>

索引.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>
4

1 回答 1

3

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

找不到完全合格的类:com.sun.facelets.FaceletViewHandler

显然,JBoss 5.x 没有附带 Facelets 1.x(可能非常好,因为它不是标准 Java EE 5 的一部分)。您需要自己在 webapp 的/WEB-INF/lib. 您可以从此处的 Maven 存储库中获取它。就是jsf-facelets.jar文件。

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

于 2012-12-13T22:36:20.037 回答