有没有人知道如何在ui:repeat facelets标签中获取元素的索引?
<ui:repeat id="topTenGrd" var="dream" value="#{dreamModifyBean.topDreams}">
<h:outputText class="dream-title uppercase" value="#{dream.number}. #{dream.title}" />
</ui:repeat>
指定"varStatus"属性的值:
<ui:repeat id="..." var="..." value="..." varStatus="myVarStatus">
您可以通过EL访问循环索引:
#{myVarStatus.index}
此外,以下属性可用于varStatus:
有关更多详细信息,请参见:
https://docs.oracle.com/javaee/7/javaserver-faces-2-2/vdldocs-facelets/ui/repeat.html
<ui:repeat id="repeatOne" var="listofValues" varStatus="myVarStatus"> </ui:repeat>
使用UI Repeat,我们可以访问与列表“listofValues”相关联的变量的值。
使用varStatus,我们可以创建另一个变量来保存不同类型的信息。例如,在我们的列表中使用#{myVarStatus.index}
来创建表格,我们可以使用此信息作为列表上的索引。
1.
2.
3.
当然,如果您将数组指定为从0开始,则列表也将如此,除非您为每个添加1。 #{myVarStatus.index + 1}
这些在需要使用嵌套的2个UI:Repeat
的2D数组中也非常有用。
属性 ___Getter_________描述
current getCurrent() The item (from the collection) for the current round of iteration
index getIndex() The zero-based index for the current round of iteration
count getCount() The one-based count for the current round of iteration
first isFirst() Flag indicating whether the current round is the first pass through the iteration
last isLast() Flag indicating whether the current round is the last pass through the iteration
begin getBegin() The value of the begin attribute
end getEnd() The value of the end attribute
step getStep() The value of the step attribute
附加文档链接: