1

Is there any way using EL to retrieve a children list so i can iterate through it with

<ul>
   <ui:repeat value="#{Magic El expression}" var="children" >
      <li>
      <p> #{children.title} *</p>
      </li>
   </ui:repeat>
</ul>
<div>
 <cc:insertChildren />
</div>

* perhaps #{children.attrs.title} I don't know?

What I'm trying to do here is create a Tab composite component. I know libraries such as primefaces offer tabview etc. Yet I need to create my own because of extended jquery functionality. Plus I'm working with a specific template. I need to get the tabs title to create a list for tabs. Tabs are children components is there anyway i can iterate and fetch their attributes? I mean primefaces does that somehow.

If you look at their html markup they create an unordered list with the titles of each children tabview component. How is that implemented?

arg20
  • 4,893
  • 1
  • 50
  • 74
  • May be I didnt understand the question correctly. Can you not just use nested ui:repeat? – CoolBeans Feb 15 '11 at 04:19
  • I can, but My question is regarding how to get a composite component's children components. Once I get the list of children components I can iterate through them but how do I get that list? – arg20 Feb 15 '11 at 04:33

2 Answers2

2

If the markup you show is inside a composite component (I guess it is), then the following is the expression that will give you access to its children:

#{component.getCompositeComponentParent(component).children}

Slightly related question: In JSF2, how to know if composite component has children?

Community
  • 1
  • 1
Arjan Tijms
  • 37,782
  • 12
  • 108
  • 140
  • I know that the children has a title attribute, how do I access it? the child.title doesnt work – arg20 Feb 27 '11 at 09:05
0

If you Composite Component is an instance of : javax.faces.component.UINamingContainer Try this:

    <c:forEach items="#{cc.children}" varStatus="loop" var="child">
      loop[#{loop.index}]: #{child.getAttributes().get('title')}
    </c:forEach>

You can easily debug which instance are your JSF variables by printing them to the page like #{cc} or #{component}

Cheers!

Bill_BsB
  • 314
  • 3
  • 14