title: JSF composite:actionSource in nested composite components
body: <p>According to the <a href="http://javaserverfaces.java.net/nonav/docs/2.1/vdldocs/facelets/composite/interface.html" rel="nofollow">JSF documentation</a> for <code>&lt;composite:interface&gt;</code>:</p>
  
  <blockquote>
    <p><strong>Nesting of composite components</strong></p>
    
    <p>The implementation must support nesting of composite components.
    Specifically, it must be possible for the 
    section of a composite component to act as the using page for another
    composite component. When a composite component exposes a behavioral
    interface to the using page, such as a ,
    ,  or other
    behavioral interface, it must be possible to “propogate” the exposure
    of such an interface in the case of a nested composite component. The
    composite component author must ensure that the value of the name
    attributes exactly match at all levels of the nesting to enable this
    exposure to work. The implementation is not required to support
    “re-mapping” of names in a nested composite component.</p>
  </blockquote>
  
  <p>It goes on to show an example of nesting <code>&lt;composite:actionSource&gt;</code> however, I have been testing an example almost exactly like that and it doesn't work.  Here is my code:</p>
  
  <p><strong>Inner Composite Component:</strong></p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  
  &lt;html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
    xmlns:composite="http://java.sun.com/jsf/composite"&gt;
  
  &lt;composite:interface&gt;
    &lt;composite:attribute name="actionText" 
      type="java.lang.String" default="nestedastest action" /&gt;
    &lt;composite:actionSource name="someaction" /&gt;
  &lt;/composite:interface&gt;
  
  &lt;composite:implementation&gt;
    &lt;h:commandLink id="someaction"&gt;#{cc.attrs.actionText}&lt;/h:commandLink&gt;
  &lt;/composite:implementation&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>Outer Composite Component:</strong></p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  
  &lt;html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
    xmlns:composite="http://java.sun.com/jsf/composite"
    xmlns:test="http://java.sun.com/jsf/composite/components/test"&gt;
  
  &lt;composite:interface name="nestedActionTester"
    displayName="A test composite component for nested actions"&gt;
    &lt;composite:attribute name="actionText" 
      type="java.lang.String" default="astest action" /&gt;
    &lt;composite:actionSource name="someaction" /&gt;
  &lt;/composite:interface&gt;
  
  &lt;composite:implementation&gt;
    &lt;test:nestedastest actionText="#{cc.attrs.actionText}" /&gt;
  &lt;/composite:implementation&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>Facelet:</strong></p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  
  &lt;html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
    xmlns:test="http://java.sun.com/jsf/composite/components/test"&gt;
  
  &lt;h:head /&gt;
  &lt;h:body&gt;
    &lt;ui:composition template="template.xhtml"&gt;
      &lt;ui:define name="content"&gt;
        &lt;h:form id="communityMembersForm"&gt;
          &lt;div&gt;
            &lt;test:astest&gt;
              &lt;f:actionListener for="someaction"
                binding="#{testController.someActionActionListener}" /&gt;
            &lt;/test:astest&gt;
          &lt;/div&gt;
          &lt;div&gt;
            &lt;test:nestedastest&gt;
              &lt;f:actionListener for="someaction"
                binding="#{testController.someActionActionListener}" /&gt;
            &lt;/test:nestedastest&gt;
          &lt;/div&gt;
        &lt;/h:form&gt;
      &lt;/ui:define&gt;
    &lt;/ui:composition&gt;
  &lt;/h:body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>Managed Bean:</strong></p>
  
  <pre><code>package test.controller;
  
  
  import javax.faces.bean.ManagedBean;
  import javax.faces.bean.ViewScoped;
  import javax.faces.event.AbortProcessingException;
  import javax.faces.event.ActionEvent;
  import javax.faces.event.ActionListener;
  
  
  import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;
  
  
  @ManagedBean
  @ViewScoped
  public class TestController {
      private static Logger logger = 
              LoggerFactory.getLogger( TestController.class );
  
      public ActionListener getSomeActionActionListener() {
          return new ActionListener() {
              @Override
              public void processAction( ActionEvent event ) 
                      throws AbortProcessingException {
                  logger.debug( "someaction occurred..." );
              }
  
          };
      }
  }
  </code></pre>
  
  <p>I am using Mojarra 2.1.13:</p>
  
  <pre><code>&lt;dependency&gt;
    &lt;groupId&gt;com.sun.faces&lt;/groupId&gt;
    &lt;artifactId&gt;jsf-api&lt;/artifactId&gt;
    &lt;version&gt;2.1.13&lt;/version&gt;
    &lt;type&gt;jar&lt;/type&gt;
    &lt;scope&gt;compile&lt;/scope&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
    &lt;groupId&gt;com.sun.faces&lt;/groupId&gt;
    &lt;artifactId&gt;jsf-impl&lt;/artifactId&gt;
    &lt;version&gt;2.1.13&lt;/version&gt;
    &lt;type&gt;jar&lt;/type&gt;
    &lt;scope&gt;runtime&lt;/scope&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>On tomcat 6.0.32:</p>
  
  <pre><code>&lt;dependency&gt;
    &lt;groupId&gt;org.apache.tomcat&lt;/groupId&gt;
    &lt;artifactId&gt;el-api&lt;/artifactId&gt;
    &lt;version&gt;6.0.32&lt;/version&gt;
    &lt;type&gt;jar&lt;/type&gt;
    &lt;scope&gt;provided&lt;/scope&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
    &lt;groupId&gt;org.apache.tomcat&lt;/groupId&gt;
    &lt;artifactId&gt;servlet-api&lt;/artifactId&gt;
    &lt;version&gt;6.0.32&lt;/version&gt;
    &lt;type&gt;jar&lt;/type&gt;
    &lt;scope&gt;provided&lt;/scope&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>When I run this application, the link for <code>nestedastest action</code> (which is the link that uses the inner composite component directly) causes the action listener to run and the log message to print.  However, when the <code>astest action</code> (the outer composite component) is clicked nothing happens.  Given that this is almost exactly the example shown in the official JSF javadoc, I would expect this to work.  Any idea why it isn't? </p>
  
  <p><strong>---------- EDIT ---------</strong></p>
  
  <p>I have found that if I modify the outer composite component thusly:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  
  &lt;html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
    xmlns:composite="http://java.sun.com/jsf/composite"
    xmlns:test="http://java.sun.com/jsf/composite/components/test"&gt;
  
  &lt;composite:interface name="nestedActionTester"
    displayName="A test composite component for nested actions"&gt;
    &lt;composite:attribute name="actionText" 
      type="java.lang.String" default="astest action" /&gt;
    &lt;composite:actionSource name="someaction" targets="inner" /&gt;
  &lt;/composite:interface&gt;
  
  &lt;composite:implementation&gt;
    &lt;test:nestedastest id="inner" actionText="#{cc.attrs.actionText}" /&gt;
  &lt;/composite:implementation&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><em>Note that I added a targets attribute to the actionSource and a matching id to the nested composite component</em></p>
  
  <p>It will now chain the action appropriately.  This does make sense, but the documentation leads you to believe this is unnecessary.  Is this an error in the documentation?  Or in the implementation (I tried it out both on Mojarra 2.1.13 and MyFaces 2.1.10)?  Or in my understanding?</p>