webtier@glassfish.java.net

Re: [webtier] How do I access composite component children attributes?

From: Ed Burns <Ed.Burns_at_Sun.COM>
Date: Tue, 01 Sep 2009 17:26:34 -0700

>>>>> On Mon, 31 Aug 2009 20:06:44 -0700 (PDT), webtier_at_javadesktop.org said:

MV> I am creating composite component that must render a child composite
MV> component. Although I am iterating over three children, as shown in
MV> this example, the clientId and title attribute for each rendered
MV> child is blank.

I replaced c:forEach with ui:repeat and made some other small changes
and have it working. Here's the stuff.

Using page:

<h:form prependId="false">

  <ez:insertChildrenClientIds id="outer">
    <ez:insertChildrenContainer title="Inner 1 title" id="inner1"> First: </ez:insertChildrenContainer>
    <ez:insertChildrenContainer title="Inner 2 title" id="inner2"> Middle: </ez:insertChildrenContainer>
    <ez:insertChildrenContainer title="inner 3 title" id="inner3"> Last: </ez:insertChildrenContainer>
  </ez:insertChildrenClientIds>

</h:form>

insertChildrenClientIds:

    <composite:interface>
    </composite:interface>
    <composite:implementation>
        <div id="#{cc.clientId}">
<ul>
            <ui:repeat value="#{cc.children}" var="child">
                <li> &nbsp; <a href="#{child.clientId}">#{child.attrs.title} &nbsp; </a></li>
            </ui:repeat>
</ul>
 
        </div>
    </composite:implementation>

    <composite:interface>
        <composite:attribute name="title" type="java.lang.String"/>
    </composite:interface>
    <composite:implementation>
        <div id="#{cc.clientId}">
       <li> <composite:insertChildren/> </li>
        </div>
    </composite:implementation>

Ed

-- 
| ed.burns_at_sun.com  | office: 408 884 9519 OR x31640
| homepage:         | http://ridingthecrest.com/