1

<ui:insert>中に書き込めます<ui:include>か?コンテンツを使用しようとすると<ui:define name="jsInclude">、コンテンツが表示されません。JSF 1.2 でこれを試すと、これは機能しますが、JSF 2.2 では機能しません。

JSF 2.2 のテンプレートの概念で欠けているものを理解するのに誰か助けてくれますか?

ありがとう!!

以下は私のコードです

これがテンプレートファイルです

<!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://xmlns.jcp.org/jsf/facelets">

    <head>
        <title><ui:insert name="browserTitle">My Page</ui:insert></title>
        <ui:insert name="head"></ui:insert>
        <ui:include src="myIncludeFile.xhtml" />
    </head>

    <body>
        <div class="mainContent">
            <!-- START OF BODY CONTENT //-->
            <ui:insert name="body">Default Body</ui:insert>
            <!-- END OF BODY CONTENT //-->
        </div>
    </body>
</html>

これは含まれているファイルです

<span xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
    <ui:composition>
        <ui:insert name="jsInclude"></ui:insert>
    </ui:composition>
</span>

以下はクライアントのメインページです

<!DOCTYPE HTML>
<html 
    xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
    <ui:composition template="../templates/myTemplate.xhtml">

        <ui:define name="browserTitle">My Page</ui:define>

        <ui:define name="head">
            This is head
        </ui:define>

        <ui:define name="jsInclude">
            This is js include!
        </ui:define>

        <ui:define name="body">
            This is body!
        </ui:define>
    </ui:composition>
</html>
4

1 に答える 1

0

ui:decorateの代わりに使用しui:insertます。この質問を確認してください。

于 2016-05-09T15:50:50.057 に答える