有没有人知道一种方法来获取ui中元素的索引:repeat facelets tag?Facelets重复标签索引
<ui:repeat id="topTenGrd" var="dream" value="#{dreamModifyBean.topDreams}">
<h:outputText class="dream-title uppercase" value="#{dream.number}. #{dream.title}" />
</ui:repeat>
有没有人知道一种方法来获取ui中元素的索引:repeat facelets tag?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://javaserverfaces.java.net/docs/2.2/vdldocs/facelets/ui/repeat.html
Brian的回答很好,但我认为它对信息可能更具描述性。
我们创建UI:重复
<ui:repeat id="repeatOne" var="listofValues" varStatus="myVarStatus"> </ui:repeat>
使用UI重复,我们可以从我们跟名单“listofValues”关联的变量访问值。
使用varStatus我们可以创建另一个变量来保存不同类型的信息。例如,在我们的列表中使用#{myVarStatus.index}
来创建表格,我们可以将这些信息用于我们列表中的索引。
1.
2.
3.
如果您指定数组0开始当然再等会你的列表,除非你加1,每个。 #{myVarStatus.index + 1}
这些对于需要使用嵌套的2 UI:Repeat
的二维数组也非常有用。
物业___Getter_________Description
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
的链接其他文档: