Reputation: 43
Is there a way to override the <ui:define>
that JSF templating offers?
For instance file main.xhtml
, that includes a template file, contains:
<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>
If I want to create a main2.xhtml
file that is identical to the main.xhtml
, with the exception that it uses a different menu is there the possibility to do something like this:
<ui:include src="main.xhtml"/>
<ui:define name="menu"><ui:include src="path_to_menu_2"/></ui:define>
Where the <ui:define name="menu">
overrides the tag with the same name attribute in main.xhtml
Upvotes: 3
Views: 2310
Reputation: 1108632
Just specify main.xhtml
as template of 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>
Upvotes: 3