Skip executing <ui:include> when parent UI component is not rendered

Viewed 9601

I have the following construct at several places in my webapp in order to conditionally render page fragments depending on some actions:

<h:panelGroup rendered="#{managedBean.serviceSelected == 'insurance'}">
    <ui:include src="/pages/edocket/include/service1.xhtml" />
</h:panelGroup>

I have observed, that the <ui:include> is still executed even when the rendered attribute evaluates false. This unnecessarily creates all backing beans associated with the service1.xhtml file which is been included.

How can I skip executing the <ui:include> when the parent UI component is not rendered, so that all those backing beans are not unnecessarily created?

2 Answers
Related