2016-12-01 30 views
0

我正在設計一個網站,其中我想在所有頁面中包含我的Navbar,問題是我每寫navbar代碼裏面的ui:composition標籤就會比bootstrap熄滅。沒有這個標籤,一切工作正常。Bootstrap不能在UI組合標籤下工作JSF

工作碼

<?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:ui="http://java.sun.com/jsf/facelets" 
    xmlns:h="http://java.sun.com/jsf/html" 
    xmlns:f="http://java.sun.com/jsf/core" xml:lang="en" lang="en"> 
<h:head> 


    <title>JSF 2.x Page</title> 
    <meta http-equiv="keywords" content="enter,your,keywords,here" /> 
    <meta http-equiv="description" 
     content="A short description of this page." /> 
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> 

    <h:outputStylesheet library="css" name="black.css" /> 
    <h:outputStylesheet library="css" name="bootstrap.css" /> 

    <h:outputScript library="js" name="bootstrap.js" /> 
    <h:outputScript library="js" name="bootstrap.min.js" /> 

</h:head> 
<h:body> 

     <nav class="navbar navbar-inverse"> 
     <div class="container-fluid"> 
      <div class="navbar-header"> 
       <a class="navbar-brand" href="#">My Task</a> 
      </div> 

      <button class="btn btn-success navbar-btn">Projects</button> 
      <button class="btn btn-success navbar-btn">Objects</button> 
      <button class="btn btn-success navbar-btn">Properties</button> 
      <button class="btn btn-success navbar-btn">Property Types</button> 

     </div> 
     </nav> 

</h:body> 
</html> 

但隨着ui:composition,自舉工作不

<?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:ui="http://java.sun.com/jsf/facelets" 
    xmlns:h="http://java.sun.com/jsf/html" 
    xmlns:f="http://java.sun.com/jsf/core" xml:lang="en" lang="en"> 
<h:head> 
    <title>JSF 2.x Page</title> 
    <meta http-equiv="keywords" content="enter,your,keywords,here" /> 
    <meta http-equiv="description" 
     content="A short description of this page." /> 
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> 

    <h:outputStylesheet library="css" name="black.css" /> 
    <h:outputStylesheet library="css" name="bootstrap.css" /> 

    <h:outputScript library="js" name="bootstrap.js" /> 
    <h:outputScript library="js" name="bootstrap.min.js" /> 

</h:head> 
<h:body> 
<ui:composition> 
     <nav class="navbar navbar-inverse"> 
     <div class="container-fluid"> 
      <div class="navbar-header"> 
       <a class="navbar-brand" href="#">My Task</a> 
      </div> 

      <button class="btn btn-success navbar-btn">Projects</button> 
      <button class="btn btn-success navbar-btn">Objects</button> 
      <button class="btn btn-success navbar-btn">Properties</button> 
      <button class="btn btn-success navbar-btn">Property Types</button> 

     </div> 
     </nav> 
</ui:composition> 

</h:body> 
</html> 
+0

是不是c在UI之外的ode:compsition忽略?你爲什麼不使用模板並在那裏放置引導程序?看到這裏:http://stackoverflow.com/questions/6525050/understand-the-purpose-of-jsf-uicomposition – Tim

+0

一切都被忽略內部或外部的組成標籤 –

+0

它不是真的一個問題 - 代碼之外的標籤將被忽略。因此,我建議使用包含boostrap和您的作文的模板 – Tim

回答

1

ui的:組合物代碼用於經由它的「模板」來引用模板 屬性,如:

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

模板是ju st常規面部文件,其中包含一個或多個帶有名稱屬性的<ui:insert> 標記,您可以使用<ui:define>標記使用模板從文件中引用該屬性。 例如,如果您的模板包含:

<ui:insert name="top"> 

比你可以從另一個文件<ui:composition>標籤內等引用它:

<ui:define name="top"> 

生成的HTML將在一個只從模板<ui:define>創建部分被替換爲你的<ui:insert>標記中生成的任何html ... 因此,如果沒有模板,您不會創建正確的html,也不會創建正確的html。

相關問題