[英]How to iterate over an arraylist in jsf without `<t:datatable>` or `<t:datalist>`
How to get the following result in JSF with 如何在JSF中获得以下结果
<div id="tagcloud">
<a href="#" rel="0.1">Lorem</a>
<a href="#" rel="2">ipsum</a>
<a href="#" rel="3">dolor</a>
<a href="#" rel="4">sit</a>
<a href="#" rel="5">amet,</a>
<a href="#" rel="6">consectetur</a>
<a href="#" rel="7">adipisicing</a>
</div>
I tried <t:datatable>
or <t:datalist>
but both are not able to. 我尝试过<t:datatable>
或<t:datalist>
但两者都无法做到。
Assuming you use Facelets, the following should do it: 假设您使用Facelets,以下应该这样做:
<div id="tagcloud">
<t:dataList value="#{backingBean.items}" var="item" layout="simple">
<a href="#" rel="#{item.rel}">#{item.name}</a>
</t:dataList>
</div>
If you're using JSP (hope not), you can replace #{item.name} with an h:outputText. 如果您正在使用JSP(希望不是),则可以使用h:outputText替换#{item.name}。
backingBean.items
in the example points to some backing bean that returns a List
with the values that differ for each row. backingBean.items
中的backingBean.items
指向一些返回List
辅助bean,其中每个行的值都不同。
why not use jstl 为什么不使用jstl
<c:forEach var="person" items="${people.people}">
<tr>
<td>${person.name}</td>
<td>${person.age}</td>
<td>${person.height}</td>
</tr>
</c:forEach>
or 要么
<ui:repeat value="#{TableBean.perInfoAll}" var="info">
<li>
<h:inputText value="#{info.id}" />
<h:inputText value="#{info.name}" />
</li>
</ui:repeat>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.