Working with <ui:include> and <f:viewParam>
You may think that combining <ui:include>
with <f:viewParam>
is a strange combination, and maybe it is. But, as you know, <ui:include>
is able to encapsulate and reuse content from multiple pages, while <f:viewParam>
can be useful for adding view parameters in links (using the GET query string). This means that we can take parameters passed on the current page via <f:viewParam>
and use them in <ui:include>
.
For example, in the current page, we can include a random page, or a page whose name was hardcoded as the value of a view parameter in an outcome. We can also use the includeViewParams
attribute to tell other pages to include the same content as the current page. These three examples are just on open gate to more scenarios. The following example speaks for itself:
<h:head> <title></title> <f:metadata> <f:viewParam name="in" value="#{randomInBean...