作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
好的,要在另一个页面中包含一个页面,我需要 <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/
我在 StackOverflow 和其他地方看到了很多与此类似的问题,但没有一个直接解决我的问题。我正在 THREE.js 中使用凸包生成器生成 n 边多面体。我想将方形纹理映射到每个多面体的每个面上
我是一名优秀的程序员,十分优秀!