gpt4 book ai didi

java - Facelets:只需要一个页面的 标签

转载 作者:行者123 更新时间:2023-11-30 09:46:23 25 4
gpt4 key购买 nike

好的,要在另一个页面中包含一个页面,我需要 <ui:include src="pageName"/>标签。但是如果我只想包含页面的一部分呢?

让我解释一下:我有一个带有标签 <ui:insert name="body"/> 的模板及其他<ui:insert.../>标签。页面 List.xhtml 使用此模板,当然会填充所有模板标签。现在,在另一个名为 Create.xhtml(使用相同模板)的页面中,在某个时刻,我只想放置 List.xhtml 的正文标签内容,而不是其他标签。可能吗?

谢谢你的回答。

最佳答案

最简单的方法可能是将 List.xhtml 的正文部分拆分成它自己的 <ui:composition> .然后你可以在 <ui:decorate> 中重新使用它在您需要的页面中。这将是执行此操作的"template"方式。

或者,您可以创建一个 <ui:component>出 body 部分。这将是这样做的“组件”方式。两者都应该实现相同的基本目标,但组合/装饰可能更简单。

更新示例(另请参见 here)。

commonBody.xhtml

...
<ui:composition>
<p>This is some common body.</p>
<p><ui:insert name="dynamicBody" /></p>
</ui:composition>

列表.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>
...

会输出类似的东西

...
<body>
<h1>This is the List.xhtml</h1>
<p>This is some common body.</p>
<p>Body of List.xhtml</p>
</body>
...

关于java - Facelets:只需要一个页面的 <ui:define> 标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7162630/

25 4 0
文章推荐: java - Java注解的错误使用
文章推荐: python - 如何让 CatBoost get_object_importance 与 AUC 配合使用?
文章推荐: python - 如何在pytorch中使用反向传播和自定义损失?
文章推荐: javascript - jQuery:带有关闭按钮的 fadeOut
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com