Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/jsf/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Facelets:只需要一个<;用户界面:定义>;页面标记_Java_Jsf_Facelets - Fatal编程技术网

Java Facelets:只需要一个<;用户界面:定义>;页面标记

Java Facelets:只需要一个<;用户界面:定义>;页面标记,java,jsf,facelets,Java,Jsf,Facelets,好的,要在另一个页面中包含一个页面,我需要标记。但是如果我只想包含一页的一部分 让我解释一下: 我有一个模板,其中包含标签和其他标签。 一个页面List.xhtml使用这个模板,当然,它会填充所有模板标记。现在,在另一个名为Create.xhtml(使用相同模板)的页面中,在某一点上,我只想放置List.xhtml的body标记内容,而不是其他标记。可能吗 谢谢您的回答。最简单的方法可能是将列表的body部分拆分为自己的。然后,您可以在需要它的页面中与一起重复使用它。这将是一种“模板”方式 或者

好的,要在另一个页面中包含一个页面,我需要
标记。但是如果我只想包含一页的一部分

让我解释一下: 我有一个模板,其中包含标签
和其他
标签。 一个页面List.xhtml使用这个模板,当然,它会填充所有模板标记。现在,在另一个名为Create.xhtml(使用相同模板)的页面中,在某一点上,我只想放置List.xhtml的body标记内容,而不是其他标记。可能吗


谢谢您的回答。

最简单的方法可能是将列表的body部分拆分为自己的
。然后,您可以在需要它的页面中与
一起重复使用它。这将是一种“模板”方式

或者,您可以在正文部分之外创建一个
。这将是实现这一目标的“组件”方式。两者应该达到相同的基本目标,但构图/装饰可能更简单

更新 示例(另请参见)

commonBody.xhtml

...
<ui:composition>
<p>This is some common body.</p>
<p><ui:insert name="dynamicBody" /></p>
</ui:composition>
。。。
这是一个共同的团体

List.xhtml

...
<body>
<h1>This is the List.xhtml</h1>
<ui:decorate template="commonBody.xhtml">
<ui:define name="dynamicBody">Body of List.xhtml</ui:define>
</ui:decorate>
</body>
...
。。。
这是List.xhtml
List.xhtml的主体
...
输出类似于

...
<body>
<h1>This is the List.xhtml</h1>
<p>This is some common body.</p>
<p>Body of List.xhtml</p>
</body>
...
。。。
这是List.xhtml
这是一个共同的团体

List.xhtml的主体

...
<body>
<h1>This is the List.xhtml</h1>
<ui:decorate template="commonBody.xhtml">
<ui:define name="dynamicBody">Body of List.xhtml</ui:define>
</ui:decorate>
</body>
...
...
另一种方式:

template.xhtml:

......

<ui:insert name="body"/>

......
。。。。。。
......
List.xhtml:

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

..............

     <ui:define name="body">

          <ui:include src="ListContent.xhtml"/>

     </ui:define>

..............

</ui:composition>

..............
..............
ListContent.xhtml

<ui:component xmlns....>

     Content I can reuse in other pages different by List.xhtml 
     (without see List.xhtml entire content, which is the scope of this question),
     simply writing "<ui:include src="ListContent.xhtml"/>" in the target page code.

</ui:component>

通过List.xhtml,我可以在其他不同页面中重复使用的内容
(无需参阅List.xhtml的全部内容,这是本问题的范围),
只需在目标页面代码中写入“”。

希望能帮助别人。

对不起,我不明白你说什么,你能写一个例子吗?是的,现在我明白了,很简单!非常感谢。此外,我还发现了另一种方法,用组件进行实验,见下文。