title: Ajax attached to Composite Component updates model but does not fire listener
body: <p>I have a custom component <code>location</code>. I want that, when a change is done, the model is update so another component (an autocomplete) is to show only results related to the <code>location</code> value. Also, that component is rerendered to reset it.</p>
  
  <p>I have a page with the following code (simplified):</p>
  
  <pre><code>&lt;h:form id="ticketForm"&gt;
    ...
    &lt;loc:location id="locationId"                         &lt;-- CUSTOM COMPONENT
      hiddenFieldValue="#{ticketCtrl.ticket.location}"
      visibleFieldValue="#{ticketCtrl.ticket.locationDescription}"
      rendered="#{ticketCtrl.ticketModifiable}"&gt;
  
      &lt;f:ajax event="changeLocation" render=":ticketForm:gfhId"       &lt;-- AJAX CALL.
        execute=":ticketForm:locationId" listener="#{ticketCtrl.locationListener}"/&gt;
    &lt;/loc:location&gt;
    ...
  &lt;/h:form&gt;
  </code></pre>
  
  <p>When the value in the component is changed, the model is updated and <code>:ticketForm:gfhId</code> is rendered as needed, but the listener(which performs additional resets) is not executed.</p>
  
  <p>Attaching the ajax to a simpler control results in the listener being executed; v.g.</p>
  
  <pre><code>&lt;h:inputText id="contactId"
    value="#{ticketCtrl.ticket.contactPerson}"
    disabled="#{not ticketCtrl.ticketModifiable}"&gt;
    &lt;f:ajax event="change" render=":ticketForm:gfhId"
      execute=":ticketForm:locationId" listener="#{ticketCtrl.locationListener}"/&gt;
  &lt;/h:inputText&gt;
  </code></pre>
  
  <p>works perfectly.</p>
  
  <p>I do not know if it may be related as how the <code>changeLocation</code> event is fired; inside my component I define it as</p>
  
  <pre><code>&lt;composite:interface&gt;
     ...
     &lt;composite:clientBehavior name="changeLocation" event="change" targets="visibleId"/&gt;
  &lt;/composite:interface&gt;
  </code></pre>
  
  <p>with <code>visibleId</code> being a readonly text; when it is changed by javascript I fire the <code>change</code> event on it with JS.</p>
  
  <pre><code>function launchEvent(fieldName) {
    if ("fireEvent" in fieldName) {
      fieldName.fireEvent("onchange");
    } else {
      var evt = document.createEvent("HTMLEvents");
      evt.initEvent("change", false, true);
      fieldName.dispatchEvent(evt);
    }
  }
  </code></pre>
  
  <p>The info I find in other questions is about making ajax an inner part of the composite component, here I want ajax detached because I probably won't need it in other uses of the component.</p>
  
  <p>I am using JBoss 6.1 wih Mojarra 2.1.9 and Richfaces 4.</p>
  
  <p>Thanks in advance.</p>
  
  <p>UPDATE:</p>
  
  <p>Even after finding jarek.jpa's answer right, if someone wants to check the code it is here:</p>
  
  <p>The composite component
  <a href="http://pastebin.com/9wqMVfR5" rel="nofollow">http://pastebin.com/9wqMVfR5</a></p>
  
  <p>The main form
  <a href="http://pastebin.com/i39ys2D9" rel="nofollow">http://pastebin.com/i39ys2D9</a></p>