0

How can I nest composite-components in each other?

As an example, I have two composites representing the menu and the menu item which are used like:

<html ... xmlns:test="http://java.sun.com/jsf/composite/test">
...
<test:menu>
    <test:menuItem value="#{someBean.someValue}"/>
    <test:menuItem value="#{someBean.someOtherValue}"/>
</test:menu>

I would like to get it to render as:

<select>
    <option value="#{someBean.someValue}">#{someBean.someValue}</option>
    <option value="#{someBean.someOtherValue}">#{someBean.someOtherValue}</option>
</select>

The menu.xhtml is implemented as follows:

<composite:implementation>
    <select>
        <!-- How to get the <test:menuItem> here? -->
    </select>
</composite:implementation>

The menuItem.xhtml is implemented as follows:

<composite:implementation>
    <option value="#{cc.attrs.value}"> #{cc.attrs.value} </option>
</composite:implementation>

How do I get the <test:menuItem> in the place as identified by the comment in <test:menu> implementation?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
L. Monty
  • 872
  • 9
  • 17

1 Answers1

2

Use the composite:insertChildren tag like this:

<composite:implementation>
    <select>
        <composite:insertChildren/>
    </select>
</composite:implementation>
dratewka
  • 2,104
  • 14
  • 15