Ion*_*nut 2 jsf facelets composite-component jsf-2
在JSP和JSTL中,我会正常地做这样的事情:
<c:forEach items="${userList}" var = "user">
<div id = "user-block">
<h1>${user.name}</h1>
<div id = "user-description">
<p>${user.description}</p>
</div>
<ul>
<li> Age: ${user.age} </li>
<li> City: ${user.city} </li>
<li> Country: ${user.country} </li>
</ul>
</div>
</c:forEach>
Run Code Online (Sandbox Code Playgroud)
我试图使用Facelet复合组件获得相同的结果:
<cc:interface>
<cc:attribute name="value" type="java.util.List" required="true" shortDescription="The list of objects that should be displayed"/>
</cc:interface>
<cc:implementation>
<div class = "event-block">
</div>
</cc:implementation>
Run Code Online (Sandbox Code Playgroud)
问题是我不知道如何迭代#{cc.attrs.value}中的对象.
LE: 我想知道是否有办法在不使用JSP或JSTL的情况下解决这个问题
小智 8
用ui:repeat
而不是c:forEach
.
<ui:repeat value="#{cc.attrs.value}" var="user">
<h1>#{user.name}</h1>
...
</ui:repeat>
Run Code Online (Sandbox Code Playgroud)
请参阅http://www.ninthavenue.com.au/blog/c:foreach-vs-ui:repeat-in-facelets以进一步比较c:forEach
和ui:repeat
.