title: Does <ui:composition> go before or after <body>?
body: <p>I am using JSF2 facelets. </p>
  
  <p>I am trying to insert a piece of code from one page into the other using <code>&lt;ui:composition&gt;</code> and <code>&lt;ui:insert&gt;</code> tags. </p>
  
  <p>I have page A, which includes code from page B. </p>
  
  <p><code>&lt;h:form id="formIdPageA"&gt;</code>
  ...</p>
  
  <p><code>&lt;h:form id="formIdPageB"&gt;</code></p>
  
  <p>The problem seems to be form id, since I get error:</p>
  
  <p><code>System error: Cannot find component with identifier ":formIdPageA:fileListId" in view.</code></p>
  
  <p>Here is a piece of code from page B that gets inserted into page A. Here ids can be seen:</p>
  
  <pre><code>                    &lt;tr&gt;
                          &lt;td colspan="2"&gt;
                              &lt;p:selectOneMenu id="locationId" value = "#{PFMultiFileSelectMgmtBean.selectedLocationId}"&gt;
                                  &lt;p:ajax update=":formIdPageA:fileListId" listener="#{PFMultiFileSelectMgmtBean.LocationChangeEvent}"/&gt;
                                  &lt;f:selectItems value="#{PFJobMgmtBean.outputLocationList}"/&gt;                                
                              &lt;/p:selectOneMenu&gt;
                          &lt;/td&gt;
                          &lt;td&gt;                                
                          &lt;/td&gt;
                      &lt;/tr&gt;
                      &lt;tr&gt;
                          &lt;td colspan="2"&gt;
                              &lt;p:selectManyCheckbox id="fileListId" value="PFMultiFileSelectMgmtBean.selectedFiles"  layout="pageDirection"&gt;  
                                  &lt;f:selectItems value="#{PFMultiFileSelectMgmtBean.fileNames}" /&gt;  
                              &lt;/p:selectManyCheckbox&gt;  
                          &lt;/td&gt;
                      &lt;/tr&gt;   
  </code></pre>
  
  <p>And this is how I insert it in page A:</p>
  
  <pre><code>&lt;p:dialog id="basicDialog" header="Select Files" widgetVar="dlgMultiFileSelect" modal="true" height="500" width="500" resizable="false"&gt;
      &lt;ui:insert&gt;  
          &lt;ui:include src="/pageB.xhtml"/&gt;
      &lt;/ui:insert&gt;  
  &lt;/p:dialog&gt;
  </code></pre>
  
  <p>Does anyone know if it is possible to include page like this? Does <code>&lt;ui:composition&gt;</code> go before body tab or after in page B? Is this ok:</p>
  
  <pre><code>&lt;body&gt;
      &lt;f:view&gt;    
          &lt;h:form id="formIdPageB"&gt;
                  &lt;ui:composition&gt;...
  </code></pre>
  
  <p>?</p>
  
  <p><strong>Ok, found it:</strong></p>
  
  <p>The problem was that I used PrimeFaces component <code>&lt;p:dialog&gt;</code> and placed it in page A outside <code>&lt;h:form&gt;</code> and outside <code>&lt;body&gt;</code>, like this:</p>
  
  <pre><code>   &lt;/h:form&gt;
   &lt;/f:view&gt;      
  &lt;/body&gt;
  &lt;p:dialog...&gt;        
     &lt;ui:include src="/pageB.xhtml"/&gt;       
  &lt;/p:dialog&gt;
  </code></pre>
  
  <p>That seems to be wrong. Now I moved <code>&lt;p:dialog&gt;</code> inside form and all is ok.</p>