title: AJAX within nested JSF Composite Component
body: <p>I'm having a bit of trouble getting AJAX calls to fire properly in a nested composite component with Mojarra 2.0.3 and PrimeFaces.</p>
  
  <p>The child composite component looks something like this:</p>
  
  <pre><code>&lt;cc:interface componentType="therapy"&gt;
      &lt;cc:attribute name="therapyType" type="java.lang.String" required="true"/&gt;
      &lt;cc:attribute name="patientId" type="java.lang.String" required="true"/&gt;
      &lt;cc:attribute name="showHistory" type="java.lang.Boolean" required="false" default="true"/&gt;
      &lt;cc:attribute name="width" type="java.lang.String" required="false" default="350px"/&gt;
      &lt;cc:attribute name="maxHistory" type="java.lang.String" required="false" default="3"/&gt;
      &lt;cc:attribute name="collectDoctor" type="java.lang.Boolean" required="false" default="false"/&gt;
      &lt;cc:attribute name="collectCareDate" type="java.lang.Boolean" required="false" default="false"/&gt;
      &lt;cc:attribute name="important" type="java.lang.Boolean" requred="false" default="false"/&gt;
  &lt;/cc:interface&gt;
  
  &lt;cc:implementation&gt;
  
      &lt;script&gt;
          function #{cc.clientId}Toggle(){
              $("##{cc.clientId}_newbutton").toggle();
              $("##{cc.clientId}_savebuttons").toggle();
  
              if(#{cc.attrs.collectDoctor}){
                  $("##{cc.clientId}_doctor").toggle();
              }
  
              if(#{cc.attrs.collectCareDate}){
                  $("##{cc.clientId}_care").toggle();
              }
  
              $("##{cc.clientId}_newTherapy").toggle(50);
          }
  
          function #{cc.clientId}rowHighlight(event){
              if(event.status == 'begin'){
                  $("##{cc.clientId}_loader").toggle();
              }
              if(event.status == 'success'){
                  $("##{cc.clientId}\\:histTable tr:eq(1)").effect("highlight", {color:"#FED17A", easing:"easeInCubic"}, 2000);
              }
          }
  
          $(function(){
              if(#{cc.attrs.important}){
                  $("div[class~='ui-panel-titlebar'][id^='#{cc.clientId}']").css("background", "#FED17A");
              }
          });
      &lt;/script&gt;
  
      &lt;h:form prependId="false"&gt;
          &lt;p:panel styleClass="mcoPanel" style="width:#{cc.attrs.width};"&gt;
                  &lt;f:facet name="header"&gt;
                      &lt;h:panelGroup&gt;
                          &lt;span id="#{cc.clientId}_title"&gt;#{cc.myType.word}&lt;/span&gt;
                          &lt;span id="#{cc.clientId}_newbutton" class="mcoPanel-controls"&gt;
                              &lt;span onclick="#{cc.clientId}Toggle();"&gt;
                                  &lt;h:graphicImage name="page_new.gif" library="images"/&gt;
                              &lt;/span&gt;
                          &lt;/span&gt;
                          &lt;span id="#{cc.clientId}_savebuttons" class="mcoPanel-controls" style="display:none;"&gt;
                              &lt;span id="#{cc.clientId}_loader" style="display:none;"&gt;
                                  &lt;h:graphicImage name="ajax-loader.gif" library="images" height="16" width="16"/&gt;
                              &lt;/span&gt;
                              &lt;h:commandLink action="#{cc.saveNewTherapy}"&gt;
                                  &lt;f:ajax execute="newOnTherapy newExemption newDoctor newCareDate" render="@form" onevent="#{cc.clientId}rowHighlight"/&gt;
                                  &lt;h:graphicImage name="action_save.gif" library="images"/&gt;
                              &lt;/h:commandLink&gt;
                              &lt;span onclick="#{cc.clientId}Toggle();"&gt;
                                  &lt;h:graphicImage name="page_cross.gif" library="images"/&gt;
                              &lt;/span&gt;
                          &lt;/span&gt;
                      &lt;/h:panelGroup&gt;
              &lt;/f:facet&gt;
              &lt;div id="#{cc.clientId}_newTherapy" class="mcoPanel-new" style="display:none;"&gt;
                  &lt;h:outputLabel for="newOnTherapy" value="Satisfied:" style="position:relative; top: -10px;"/&gt;
                  &lt;p:selectOneMenu id="newOnTherapy" label="Satisfied" value="#{cc.newOnTherapyValue}" style="width: 60px;"&gt;
                      &lt;f:selectItem itemLabel=""/&gt;
                      &lt;f:selectItems value="#{cc.yesNoList}"/&gt;
                  &lt;/p:selectOneMenu&gt;
                  &lt;br/&gt;
                  &lt;h:outputLabel for="newExemption" value="Exemption:" style="position:relative; top: -10px;"/&gt;
                  &lt;p:selectOneMenu id="newExemption" value="#{cc.newExemption}" style="width: 150px;"&gt;
                      &lt;f:selectItems value="#{cc.exemptions}"/&gt;
                  &lt;/p:selectOneMenu&gt;
                  &lt;span id="#{cc.clientId}_doctor" style="display:none"&gt;
                      &lt;br/&gt;
                      &lt;h:outputLabel for="newDoctor" value="Doctor:"/&gt;
                      &lt;p:inputText id="newDoctor" value="#{cc.newDoctor}"/&gt;
                  &lt;/span&gt;
                  &lt;span id="#{cc.clientId}_care" style="display:none"&gt;
                      &lt;br/&gt;
                      &lt;h:outputLabel for="newCareDate" value="Care Date:"/&gt;
                      &lt;p:calendar id="newCareDate" label="Care Date" value="#{cc.newCareDate}" showButtonPanel="true"&gt;
                          &lt;f:converter converterId="dateOfBirthConverter"/&gt;
                      &lt;/p:calendar&gt;
                  &lt;/span&gt;
              &lt;/div&gt;
              &lt;h:messages id="#{cc.clientId}_messages" errorClass="errorMessage"/&gt;
              &lt;p:dataTable id="histTable" value="#{cc.history}" var="item" rendered="#{cc.attrs.showHistory}"&gt;
                  &lt;!-- Table Output --&gt;
              &lt;/p:dataTable&gt;
          &lt;/p:panel&gt;
      &lt;/h:form&gt;
  </code></pre>
  
  <p>And the parent composite component looks something like this:</p>
  
  <pre><code>&lt;cc:interface&gt;
      &lt;cc:attribute name="title" type="java.lang.String" required="true"/&gt;
  &lt;/cc:interface&gt;
  
  &lt;cc:implementation&gt;
  
      &lt;h:outputScript name="containerpanel.js" library="js/components" target="head"/&gt;
  
      &lt;p:panel toggleable="true" styleClass="contentPanel" toggleSpeed="500" style="width:1100px;"&gt;
          &lt;f:facet name="header"&gt;
              #{cc.attrs.title}
              &lt;div class="ui-panel-titlebar-icon ui-corner-all ui-state-default contentSaveAll"&gt;
                  Save All
              &lt;/div&gt;
              &lt;div class="ui-panel-titlebar-icon ui-corner-all ui-state-default contentExpandAll"&gt;
                  ++
              &lt;/div&gt;
              &lt;div class="ui-panel-titlebar-icon ui-corner-all ui-state-default contentCollapseAll"&gt;
                  - -
              &lt;/div&gt;
          &lt;/f:facet&gt;
  
          &lt;cc:insertChildren&gt;
                       &lt;!-- Child components go here --&gt;
          &lt;/cc:insertChildren&gt;
  
      &lt;/p:panel&gt;
  
  &lt;/cc:implementation&gt;
  </code></pre>
  
  <p>The implementation is supposed to allow for any number of child components inside the container component.</p>
  
  <p>The child components send ajax requests and update their internal components perfectly if they are placed on a page outside of the Container component. In addition, if I use the same structure of the container, but not an actual composite component, everything works just fine.</p>
  
  <p>As soon as I place the child components as children of the Container component, that's where things go wonky. No ajax calls in the child components fire properly (i.e. the save commandLink) Using firebug to help debug this, I've been able to determine the following:</p>
  
  <ul>
  <li>The ajax post request appears to be being sent. The "begin" onevent is firing, and looking at the console in firebug shows a post being made to the server, with the proper component ids and values being sent back.</li>
  <li>The action in the backing bean is not being called. I have a print statement as the first line and it's not printing.</li>
  <li>The ajax request appears to be completing properly, the "success" onevent is firing.</li>
  <li>Nothing is being updated on the page. The form does not refresh, nor does the p:messages object at the top of the page.</li>
  </ul>
  
  <p>Obviously I can do this without the Container component, but I would prefer to be able to of course take advantage of code reuse. Am I missing something obvious here that I need to do to get the ajax to work properly?</p>