0

ビューJSFを装飾するために、JSF/Faceletsとスタイルシートを使用してプロジェクトに取り組んでいます。ビュー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;
}

これは、「Header.html」と「Footer.html」を含むメインテンプレート「Template.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>

最後に、テンプレート「Template.html」を含む私の「Main.xhtml」があります。

 <?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>

前もって感謝します :)

4

1 に答える 1

1

あなたはah:bodyをあなたの作曲の中に定義しました。

同様の質問へのリンクは次のとおりです。 how-to-include-another-xhtml-in-xhtml-using-jsf-2-0-facelets

于 2012-09-05T15:18:21.237 に答える