gpt4 book ai didi

jsf-2 - 覆盖

转载 作者:行者123 更新时间:2023-12-01 08:29:07 24 4
gpt4 key购买 nike

有没有办法覆盖 <ui:define> JSF 模板提供什么?

例如文件main.xhtml ,包含一个模板文件,包含:

<ui:define name="title">SomeTitle</ui:define>
<ui:define name="menu"><ui:include src="path_to_menu_1"/></ui:define>
<ui:define name="content">content_code_goes_here</ui:define>

如果我想创建一个 main2.xhtmlmain.xhtml 相同的文件, 除了它使用不同的菜单之外,是否有可能做这样的事情:

<ui:include src="main.xhtml"/>
<ui:define name="menu"><ui:include src="path_to_menu_2"/></ui:define>

哪里<ui:define name="menu">覆盖 main.xhtml 中具有相同名称属性的标签

最佳答案

只需将main.xhtml指定为main2.xhtml的模板即可。

main.xhtml

<ui:composition template="sometemplate.xhtml" ...>
<ui:define name="title">SomeTitle</ui:define>
<ui:define name="menu"><ui:include src="path_to_menu_1"/></ui:define>
<ui:define name="content">content_code_goes_here</ui:define>
</ui:composition>

main2.xhtml

<ui:composition template="main.xhtml" ...>
<ui:define name="menu"><ui:include src="path_to_menu_2"/></ui:define>
</ui:composition>

关于jsf-2 - 覆盖 <ui :define>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12453847/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com