First of all, this is not a valid include file syntax. You're duplicating XML prolog, HTML doctype, <html>
and <body>
tags. This would only end up as illegal HTML syntax in the final output in webbrowser.
Fix it accordingly:
<ui:composition
xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
>
<h:outputText value="One" />
<h:outputText value="Two" />
<h:outputText value="Three" />
<h:outputText value="Four" />
</ui:composition>
See also:
Coming back to your concrete question, in order to conditionally render the components, just make use of rendered
attribute. You can parameterize it by passing an <ui:param>
to <ui:include>
.
E.g.
<ui:composition
xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
>
<h:outputText value="One" rendered="#{empty hide or not hide}" />
<h:outputText value="Two" />
<h:outputText value="Three" rendered="#{empty hide or not hide}" />
<h:outputText value="Four" />
</ui:composition>
which can be used as
<ui:include src="/WEB-INF/includes/client.xhtml">
<ui:param name="hide" value="#{true}" />
</ui:include>
When <ui:param name="hide">
is omitted, or its value is not true
, then they will be shown.