Facelets模板客户端不会加载模板

时间:2019-03-28 18:30:25

标签: jsf

我有两个Facelets Template客户端,第一个是index.xhtml文件。索引文件成功加载了我的模板,但是当我尝试加载第二个Facelets客户端时,这无法加载我的模板。

模板代码

<?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:h="http://xmlns.jcp.org/jsf/html"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
    <h:head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <h:outputStylesheet library="css" name="default.css"/>
        <h:outputStylesheet library="css" name="cssLayout.css"/>
        <h:outputStylesheet library="css" name="styles.css"/>
        <title>#{faceletsAuthorController.storeName}</title>
    </h:head>
    <h:body>
        <div id="top">
            <h2>#{faceletsAuthorController.storeName}</h2>
        </div>
        <div>
            <div id="left">
                <h:form id="navForm">
                    <h:commandLink action="#{faceletsAuthorController.populateJavaRecipesAuthorList}">Java 7 Recipes</h:commandLink>
                    <br/>
                    <h:graphicImage id="javarecipes" style="width: 100px; height: 120px" library="image" name="java7recipes.png"/>
                    <br/>
                    <h:commandLink action="#{faceletsAuthorController.populateJavaEERecipesAuthorList}">Java EE 7 Recipes</h:commandLink>
                    <br/>
                    <h:graphicImage id="javaeerecipes" style="width: 100px; height: 120px" library="image" name="javaee7recipes.png"/>
                </h:form>
            </div>
            <div id="content" class="left_content">
                <ui:insert name="content">Content</ui:insert>
            </div>
        </div>
        <div id="bottom" style="position: absolute;width: 100%;bottom: 20px;">
            Written by Josh Juneau, Apress Author
        </div>
    </h:body>
</html>

index.xhtml Facelets客户端

<?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:f="http://xmlns.jcp.org/jsf/core"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
    <h:head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <title>Chapter 4 Examples</title>
    </h:head>
    <h:body>
        <ui:composition template="view/layout/custom_template.xhtml">
            <ui:define name="content">
                <h1>Chapter 4 Example</h1>
                <p>
                    Facelets
                    <br/>
                    <br/>
                    <a href="view/example04_01a.xhtml">example04_01a.xhtml: Templates</a>
                </p>
            </ui:define>
        </ui:composition>
    </h:body>
</html>

example04_01a.xhtml第二个Faceletes模板(此模板不会加载该模板)

<?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:f="http://xmlns.jcp.org/jsf/core"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
    
    <h:body>
        <ui:composition template="view/layout/custom_template.xhtml">
            
            <ui:define name="top"></ui:define>
            <ui:define name="left"></ui:define>
            <ui:define name="content">
                <h:form id="componentForm">
                    <h1>Author List for Java 7 Recipes</h1>
                    <p>
                        Below is the list of authors.  Click on the author's last name
                        for more information regarding the author.
                    </p>
                    <h:graphicImage id="javarecipes" style="width: 100px; height: 120px" library="image" name="java7recipes.png"/>
                    <br/>
                    <h:dataTable id="authorTable" border="1" value="#{faceletsAuthorController.authorList}"
                                 var="author">
                        <f:facet name="header">
                            Java 7 Recipes Authors
                        </f:facet>
                        <h:column>
                            <h:commandLink id="authorName" action="#{faceletsAuthorController.displayAuthor(author.last)}"
                                           value="#{author.first} #{author.last}"/>
                        </h:column>
                    </h:dataTable>
                    <br/>
                    <br/>
                </h:form>
            </ui:define>
            <ui:define name="bottom"></ui:define>
        </ui:composition>
    </h:body>
</html>

运行项目时,我可以看到内容或主要区域中的index.xhtml文件已完美加载,但是当我单击一个元素时,可以看到第二页但未加载模板。

谢谢您的帮助。

0 个答案:

没有答案
相关问题