2010-09-02 44 views
1

我創建了位於應用程序的根上下文中的模板(template.xhtml)。 我想將它應用到頁面(newTemplateClient.xhtml),它位於文件夾'public'中。 所以newTemplateClient.xhtml看起來是這樣的:未應用JSF模板

<?xml version='1.0' encoding='UTF-8' ?> 
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets" 
xmlns="http://www.w3.org/1999/xhtml" 
      template="./../template.xhtml"> 
          . 
          . 
          . 

我在的index.xhtml鏈接到這個網頁:

<h:link outcome="/public/newTemplateClient" value="Login"/>

<h:commandLink action="/public/newTemplateClient?faces-redirect=true" value="Login"/>

<h:commandLink action="/public/newTemplateClient" value="Login"/>

而且,只有最後的作品。當我使用前兩個頁面顯示但模板未應用時。 所以它只適用於頁面被重定向,而不是轉發。爲什麼?

在此先感謝

好吧似乎模板應用,但css文件都沒有。我使用NetBeans嚮導來創建模板和模板客戶端。 css文件位於/ resources/css /目錄。 他們是從的template.xhtml所引用:

`

<h:head> 
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
    <link href="./resources/css/default.css" rel="stylesheet" type="text/css" /> 
    <link href="./resources/css/cssLayout.css" rel="stylesheet" type="text/css" /> 
    <title><ui:insert name="title">template</ui:insert></title> 
</h:head> 

<h:body> 

    <div id="top"> 
     <ui:insert name="top">Top</ui:insert> 
    </div> 

    <div id="content" class="center_content"> 
     <ui:insert name="content">Content</ui:insert> 
    </div> 

    <div id="bottom"> 
     <ui:insert name="bottom">Bottom</ui:insert> 
    </div> 

</h:body> 

`

我如何引用CSS文件其他辦法嗎? 文件夾結構:

Root 
    public 
    newClientTemplate.xhtml 
    template.xhtml 
    index.xhtml 

回答

3

好的問題解決了。 解決方案是使用:

<h:outputStylesheet name"css/default.css"/> 
<h:outputStylesheet name"css/cssLayout.css"/> 

相反:

<link href="./resources/css/default.css" rel="stylesheet" type="text/css" /> 
<link href="./resources/css/cssLayout.css" rel="stylesheet" type="text/css" />