JSF Iterative composite component with customizable content

霸气de小男生 提交于 2019-12-03 20:50:32
Adrian Mitev

You could use <composite:insertChildren /> to be able to "pass" the child components defined to your composite component definition. Also I recommend using <ui:repeat> instead of <c:forEach> because it's a real iterative component and better suited for JSF. Here is an example how to implement your component:

<composite:interface>
    <composite:attribute name="value"/>
</composite:interface>

<composite:implementation>
  <ul>
     <ui:repeat var="item" value="#{cc.attrs.value}">
       <li>
           <composite:insertChildren />
       </li>
     </ui:repeat>
  </ul>
</composite:implementation>

Usage:

<my:list value="#{myBean.userList}">
  <h:outputText value="Test #{item.name}"/>
</my:list>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!