Facelets:只需要一个页面的标签
好的,要在另一个页面中包含一个页面,我需要
标记。但是如果我只想包含页面的一部分呢?
让我解释一下: 我有一个模板,其中包含标签
和其他
标签。 页面 List.xhtml 使用此模板,当然会填充所有模板标记。现在,在另一个名为 Create.xhtml (使用相同模板)的页面中,在某个时刻,我只想放置 List.xhtml 的正文标记内容,而不是其他标记。是否可以?
谢谢您的回答。
Okay, to include a page in another page I need <ui:include src="pageName"/>
tag. But if i want to include only a portion of a page?
Let me explain:
I have a template that has the tag <ui:insert name="body"/>
and other <ui:insert.../>
tags.
A page, List.xhtml, uses this template and, of course, fills up ALL the template tags. Now, in another page, named Create.xhtml (that uses the same template), at a certain point, i want to put ONLY the body tag content of List.xhtml, not other tags. Is it possible?
Thank you for you answers.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
最简单的方法可能是将 List.xhtml 的正文部分分解为自己的
。然后您可以在需要的页面中通过
重新使用它。这将是执行此操作的“模板”方式。或者,您可以在 body 部分之外创建一个
。这将是执行此操作的“组件”方式。两者都应该实现相同的基本目标,但组合/装饰可能更简单。更新
示例(另请参阅此处)。
commonBody.xhtml
List.xhtml
会输出类似的内容
Easiest might be to break out the body section of your List.xhtml into its own
<ui:composition>
. Then you can re-use it in with<ui:decorate>
in the pages where you need it. This would be the "template" way of doing it.Alternativly, you can create a
<ui:component>
out of the body section. This would be the "component" way of doing it. Both should achieve the same basic goal you have, but composition/decorate might be simpler.UPDATE
Example (See also here).
commonBody.xhtml
List.xhtml
Would output something like
另一种方式:
template.xhtml:
List.xhtml:
ListContent.xhtml
希望可以帮助别人。
Another way:
template.xhtml:
List.xhtml:
ListContent.xhtml
Hope can help someone.