我的<ui:define name =“content”>标记的内容未出现在JSF视图中</ui:define>

时间:2012-09-05 14:56:54

标签: html css jsf facelets

我正在使用JSF / Facelets和样式表来开发一个项目来装饰我的视图JSF。我想在我的视图XHTML的内容中放置一些图形组件(例如:“h:inputText”和“h:commandButton”标签),但这无法实现,我不知道为什么!出现的唯一部分是我的模板“Template.html”的页眉和页脚。

无论如何,这是我的“styles.css”:

body { width: 750px; }

#header 
{
   width:              100%;
   font-size:          36px;
   font-weight:        bold;
   line-height:        48px;
   background-color:   navy;
   color:              white;
}

#footer
{
   width:              100%;
   font-weight:        bold;
   background-color:   navy;
   color:              white;
}

这是主要模板“Template.html”,包括“Header.html”和“Footer.html”,我使用标签放置了我的“styles.css”:

  <!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:ui="http://java.sun.com/jsf/facelets">
 <h:head>
      <h:outputStylesheet name="css/styles.css" />      
 </h:head>
 <h:body>
 <h:panelGroup id="page" layout="block">

 <h:panelGroup id="header" layout="block">
    <ui:insert name="header">
        <ui:include src="Header.html" />
    </ui:insert>
 </h:panelGroup>

 <h:panelGroup id="container" layout="block">
    <h:panelGroup id="content" layout="block">
        <ui:insert name="content"></ui:insert>
    </h:panelGroup>
 </h:panelGroup>

 <h:panelGroup id="footer" layout="block">
    <ui:insert name="footer">
        <ui:include src="Footer.html" />
    </ui:insert>
 </h:panelGroup>

 </h:panelGroup>

 </h:body>
 </html>

Anf终于来了我的“Main.xhtml”,其中包含模板“Template.html”:

 <?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">
 <ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:a4j="http://richfaces.org/a4j" xmlns:rich="http://richfaces.org/rich" template="Template.html">
 <h:body>
 <ui:define name="content">
    <h:form>
        <h:inputText title="inputText"></h:inputText>
        <h:commandButton value="OK"></h:commandButton>
    </h:form>
 </ui:define>
 </h:body>
 </ui:composition>

提前致谢:)

1 个答案:

答案 0 :(得分:1)

你已经在你的构图中定义了一个h:body,它看起来很像。

以下是类似问题的链接。 how-to-include-another-xhtml-in-xhtml-using-jsf-2-0-facelets