有没有人知道在ui中获取元素索引的方法:重复facelets标签?
<ui:repeat id="topTenGrd" var="dream" value="#{dreamModifyBean.topDreams}">
<h:outputText class="dream-title uppercase" value="#{dream.number}. #{dream.title}" />
</ui:repeat>发布于 2011-04-06 14:50:32
指定"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
发布于 2016-11-14 23:20:41
Brian的回答很好,但我认为它可以更具描述性地描述信息。
我们创建UI:重复
<ui:repeat id="repeatOne" var="listofValues" varStatus="myVarStatus"> </ui:repeat>使用UI Repeat,我们可以访问与列表'listofValues‘关联的变量的值。
使用varStatus,我们可以创建另一个保存不同类型信息的变量。例如,在列表中使用#{myVarStatus.index}来创建表,我们可以将此信息用于列表中的索引。
1.
2.
3.
当然,如果你指定你的数组从0开始,那么你的列表也会从0开始,除非你给每个数组加1。#{myVarStatus.index + 1}
它们在需要使用嵌套的2个UI:Repeat的2D数组中也非常有用。
属性___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带链接的附加文档:
UI的重复属性:可以在here.中找到
https://stackoverflow.com/questions/5562214
复制相似问题