title: Conditionally including a Facelet file via <ui:include>
body: <p>I have 2 Facelets files (index.xhtml and report.xhtml). I use the RichFaces <code>&lt;ui:include src="report.xhtml"/&gt;</code> to load the report into the index. Works fine.
  But when I try to only show report on certain conditions, I fail! What does not work is this:</p>
  
  <p><code>&lt;ui:include src="report.xhtml" rendered="#{indexService.contentName == 'report'}"/&gt;</code>.</p>
  
  <p>The rendered attribute of ui:include does not seem to work.</p>
  
  <p>How can I load the report.xhtml into the index.xhtml on certain conditions? Where is the error in my code?</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>Half of it works now. Changing the Facelet file works with conditions. But the functionality of the loaded Facelet does not work properly. Why is that? Where is the problem in the code?</p>
  
  <p>Based on the suggestions I now have this:</p>
  
  <pre><code>&lt;h:form&gt;
      &lt;h:panelGrid&gt;
          &lt;a4j:commandLink value="Home" render="contentpanel" action="#{indexService.setContentName('home')}"/&gt;
          &lt;a4j:commandLink value="Report" render="contentpanel" action="#{indexService.setContentName('report')}"/&gt;
      &lt;/h:panelGrid&gt;
  &lt;/h:form&gt;
  &lt;a4j:outputPanel id="contentpanel"&gt;
      &lt;ui:fragment rendered="#{indexService.contentName eq 'report'}"&gt;
          &lt;ui:include src="report.xhtml" /&gt;
      &lt;/ui:fragment&gt;
  &lt;/a4j:outputPanel&gt;
  </code></pre>
  
  <p><strong>Edit 2:</strong></p>
  
  <p>This is my report Facelet. If I use  without any condition the functionality of the report Facelet works perfectly, but if I load it using the condition I posted in <em>Edit 1</em>, then the buttons of <code>&lt;rich:panelMenuItem .../&gt;</code> don't work anymore and <code>&lt;h:outputText escape="false" value="#{reportService.content}"/&gt;</code> does not load the content. Any idea why?</p>
  
  <p><strong>Edit 3:</strong></p>
  
  <p>Changed the <code>&lt;rich:panel header="Report"&gt;...&lt;/rich:panel&gt;</code>, but behaviour still unchanged.</p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:rich="http://richfaces.org/rich"
      xmlns:a4j="http://richfaces.org/a4j"&gt;
      &lt;ui:composition&gt;
          &lt;h:outputStylesheet&gt;
              .placesmenu {
                  width: 200px;
                  vertical-align: top;
              }
  
              .contentplace {
                  vertical-align: top;
              }
          &lt;/h:outputStylesheet&gt;
          &lt;h:panelGrid columns="2" width="100%" columnClasses="placesmenu, contentplace"&gt;
              &lt;rich:panel header="Places"&gt;
                  &lt;h:form&gt;
                      &lt;rich:panelMenu style="width: 170px"&gt;
                          &lt;a4j:repeat value="#{reportService.menuItems}" var="menuItem" id="repeat_layer1"&gt;
                              &lt;rich:panelMenuGroup label="#{menuItem.label}"&gt;
                                  &lt;a4j:repeat value="#{menuItem.subMenuItemList}" var="subMenuItem" id="repeat_layer2"&gt;
                                      &lt;rich:panelMenuItem label="#{subMenuItem.label}" render="reportpanel" onbeforedomupdate="#{reportService.setId(subMenuItem.id)}"/&gt;
                                  &lt;/a4j:repeat&gt;
                              &lt;/rich:panelMenuGroup&gt;
                          &lt;/a4j:repeat&gt;
                      &lt;/rich:panelMenu&gt;
                  &lt;/h:form&gt;
              &lt;/rich:panel&gt;
              &lt;rich:panel header="Report"&gt;
                  &lt;h:outputText escape="false" value="#{reportService.content}" id="reportpanel"/&gt;
              &lt;/rich:panel&gt;
          &lt;/h:panelGrid&gt;
      &lt;/ui:composition&gt;
  &lt;/html&gt;
  </code></pre>