title: Nested JSF Composite Components leading to a Stack Overflow exception
body: <h1>The problem</h1>
  
  <p>When I attempt to nest a Composite Component within itself, with some logic to end the infinite recursion I receive a stack overflow exception. My understanding is that <a href="https://stackoverflow.com/a/3343681/2187042"><code>&lt;c:xxx&gt;</code> tags run at view build time</a> so I was not expecting to have an infinite view build as I presume has been the case.</p>
  
  <p>This is the composite component <code>simpleNestable.xhtml</code></p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:composite="http://java.sun.com/jsf/composite"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:em="http://xmlns.jcp.org/jsf/composite/emcomp"
  
    xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"&gt;
  
      &lt;h:head&gt;
          &lt;title&gt;This content will not be displayed&lt;/title&gt;
      &lt;/h:head&gt;
      &lt;h:body&gt;
          &lt;composite:interface&gt;
              &lt;composite:attribute name="depth" required="true" type="java.lang.Integer"/&gt;
          &lt;/composite:interface&gt;
  
          &lt;composite:implementation&gt;
              &lt;c:if test="#{cc.attrs.depth lt 3}"&gt;
                   #{cc.attrs.depth}
                   #{cc.attrs.depth+1}
                   &lt;em:simpleNestable depth="#{cc.attrs.depth+1}" /&gt; 
  
              &lt;/c:if&gt;
  
          &lt;/composite:implementation&gt;
      &lt;/h:body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>This is how it's used</p>
  
  <p>
  </p>
  
  <p></p>
  
  <pre><code>&lt;h:head&gt;
      &lt;title&gt;Facelet Title&lt;/title&gt;
      &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt;
      &lt;h:outputStylesheet name="./css/default.css"/&gt;
      &lt;h:outputStylesheet name="./css/cssLayout.css"/&gt;
  &lt;/h:head&gt;
  &lt;h:body&gt;        
       &lt;emcomp:simpleNestable depth="1"/&gt;
  
  &lt;/h:body&gt;
  </code></pre>
  
  <p></p>
  
  <p>The Stack Overflow Exception</p>
  
  <pre><code>java.lang.StackOverflowError
      at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109)
      at javax.faces.component.UIComponentBase$AttributesMap.get(UIComponentBase.java:2407)
      at com.sun.faces.el.CompositeComponentAttributesELResolver$ExpressionEvalMap.get(CompositeComponentAttributesELResolver.java:393)
      at javax.el.MapELResolver.getValue(MapELResolver.java:199)
      at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
      at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
      at com.sun.el.parser.AstValue.getValue(AstValue.java:140)
      at com.sun.el.parser.AstValue.getValue(AstValue.java:204)
      at com.sun.el.parser.AstPlus.getValue(AstPlus.java:60)
      at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:226)
      at org.jboss.weld.el.WeldValueExpression.getValue(WeldValueExpression.java:50)
      at com.sun.faces.facelets.el.ContextualCompositeValueExpression.getValue(ContextualCompositeValueExpression.java:158)
      at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109)
      at javax.faces.component.UIComponentBase$AttributesMap.get(UIComponentBase.java:2407)
      at com.sun.faces.el.CompositeComponentAttributesELResolver$ExpressionEvalMap.get(CompositeComponentAttributesELResolver.java:393)
      at javax.el.MapELResolver.getValue(MapELResolver.java:199)
      at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
      at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
      at com.sun.el.parser.AstValue.getValue(AstValue.java:140)
      at com.sun.el.parser.AstValue.getValue(AstValue.java:204)
      at com.sun.el.parser.AstPlus.getValue(AstPlus.java:60)
  </code></pre>
  
  <h1>The Question</h1>
  
  <p>How can I nest composite components (or similar) within themselves (to a non predefined depth) without receiving a stack overflow exception</p>
  
  <h1>Why I want this</h1>
  
  <p>I have arbitrarily nested data that I want to represent within a nested collapsibleSubTable from RichFaces, alternatives to my approach are very welcome  </p>