Search code examples
jsfcomposite-component

Inner content composite component


I have my composite component <my:panel/> :

<composite:interface>
  <composite:attribute name="header" />
  <composite:attribute name="content" />
</composite:interface>

<composite:implementation>
  <div class="panel panel-default">
    <div class="panel-heading">#{cc.attrs.header}</div>
    <div class="panel-body">
      #{cc.attrs.content}
    </div>
  </div>
</composite:implementation>

And i used:

<my:panel header="My header" content="My content"  />

Well, now i want to add html (a html table e.g.) code in content attribute. How could i do for <my:tag/> works like this?

<my:tag header="My header" >
  <table style="width:100%">
    <tr>
      <th>Firstname</th>
      <th>Lastname</th>
      <th>Age</th>
    </tr>
  </table> 
</my:tag>

Solution

  • Try <composite:insertChildren/>?

    <composite:interface>
      <composite:attribute name="header" />
      <composite:attribute name="content" />
    </composite:interface>
    
    <composite:implementation>
      <div class="panel panel-default">
        <div class="panel-heading">#{cc.attrs.header}</div>
        <div class="panel-body">
          #{cc.attrs.content}
        </div>
      </div>
      <composite:insertChildren/>
    </composite:implementation>