title: JSF 2 - How can I add an Ajax listener method to composite component interface?
body: <p>I have a JSF 2 composite component that employs some Ajax behavior. I want to add a <code>listener</code> method to the <code>&lt;f:ajax&gt;</code> tag inside my composite component, but the <code>listener</code> method should be provided as a <code>&lt;composite:attribute&gt;</code> in the <code>&lt;composite:interface&gt;</code>.</p>
  
  <p>The <code>&lt;f:ajax&gt;</code> tag inside my composite component is currently hard-coded to a listener like this:</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;f:ajax
      event="valueChange"
      execute="@this"
      listener="#{controller.genericAjaxEventLogger}"
      render="#{cc.attrs.ajaxRenderTargets}" /&gt;
  </code></pre>
  
  <p>The listener method on the bean has this signature:</p>
  
  <pre><code>public void genericAjaxEventLogger(AjaxBehaviorEvent event) 
          throws AbortProcessingException {
      // implementation code...
  }
  </code></pre>
  
  <p>I want the composite component to be something like this so the page can supply its own event method, but I can't figure out the correct syntax for the interface.</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;f:ajax
      event="valueChange"
      execute="@this"
      listener="#{cc.attrs.ajaxEventListener}"
      render="#{cc.attrs.ajaxRenderTargets}" /&gt;
  </code></pre>
  
  <p><strong>How can I do this?</strong></p>
  
  <p><em><strong>UPDATED WITH SOLUTION:</em></strong></p>
  
  <p>I took the approach suggested by BalusC and it works great. The relevant snippets are:</p>
  
  <p>The interface declaration in the composite component</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;composite:interface&gt;
      &lt;composite:attribute
          name="myattributeUpdatedEventListener"
          method-signature="void listener()"
          required="true" /&gt;
      ...
  &lt;/composite:interface&gt;
  </code></pre>
  
  <p>The Ajax tag used in my composite component</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;f:ajax
      event="valueChange"
      execute="@this"
      listener="#{cc.attrs.myattributeUpdatedEventListener}"
      render="#{cc.attrs.ajaxRenderTargets}" /&gt;
  </code></pre>
  
  <p>The place in my page where I use the composite component</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;h:form&gt;
      &lt;compcomp:myCompositeComponent
          myattributeUpdatedEventListener="#{myBackingBean.updatedEventListenerXYZ}" /&gt;
  &lt;/h:form&gt;
  </code></pre>
  
  <p>And the method on my backing bean</p>
  
  <pre><code>public void updatedEventListenerXYZ() {
      // do something here...
  }
  </code></pre>