title: Use an EL expression to pass a component ID to a composite component in JSF
body: <p>Problem: I am passing an EL expression to a composite component, but the EL expression is being evaluated from inside the composite component, rather than before. The intention being that the EL expression evaluates to a string with is sent to the composite component.</p>
  
  <p>I have a composite component, <code>MenuTable</code>:</p>
  
  <pre><code>&lt;cc:interface&gt;
      &lt;cc:attribute name="model" type="nz.co.tradeintel.web.MenuTable"/&gt;
      &lt;cc.attribute name="updateId" /&gt; 
  &lt;/cc:interface&gt;
  
  &lt;cc:implementation&gt;
      &lt;h:panelGroup id="menuTable"&gt;
      &lt;table&gt;
          &lt;ui:repeat id="repeat1" value="#{cc.attrs.model.rows}" var="row"&gt;
              &lt;tr&gt;
              &lt;ui:repeat id="repeat2" value="#{row.contents}" var="entry"&gt;
                  &lt;td&gt;
                      &lt;p:commandLink action="#{cc.attrs.model.setSelected(entry)}" update="#{cc.attrs.updateId}" value="#{entry.toString()}"/&gt;
                  &lt;/td&gt;
              &lt;/ui:repeat&gt;
              &lt;/tr&gt;
          &lt;/ui:repeat&gt;
      &lt;/table&gt;
      &lt;/h:panelGroup&gt;
  &lt;/cc:implementation&gt;
  </code></pre>
  
  <p>The intention is that I pass an absolute component ID as the attribute <code>updateId</code> like this:</p>
  
  <pre><code>&lt;p:PanelGroup id="updatingPanel"&gt;
      &lt;!-- Lots of components.--&gt;
  &lt;/p:PanelGroup&gt;
  &lt;custom:MenuTable updateId="#{component.clientId}:updatingPanel" model="#{menuBackBean.menuTable}" /&gt;  
  </code></pre>
  
  <p>The problem is, the EL expression for the <code>updateId</code> is evaluated from the scope of the <code>&lt;p:commandLink /&gt;</code> within the composite component, and I get the following error:</p>
  
  <pre><code>javax.faces.FacesException: Cannot find component with identifier ":j_idt37:j_idt39:updatingPanel:j_idt61:repeat1:0:repeat2:0:j_idt65:updatingPanel" referenced from "j_idt37:j_idt39:updatingPanel:j_idt61:repeat1:0:repeat2:0:j_idt65".
  </code></pre>
  
  <p>Note: JSF thinks I am trying to update a component with and ID of <code>updatingPanel</code> which is <em>inside</em> the composite component.</p>
  
  <p>Why is the EL expression not evaluated from the outer scope: <code>&lt;custom:MenuTable/&gt;</code>?</p>
  
  <p>There are a few related answers, but I don't understand them, such as <a href="https://stackoverflow.com/questions/9205938/passing-el-expression-to-composite-component">this one</a>.</p>
  
  <p>Using Mojarra 2.1.15</p>