首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Facelets重复标签索引

Facelets重复标签索引
EN

Stack Overflow用户
提问于 2011-04-06 14:21:08
回答 2查看 58.1K关注 0票数 39

有没有人知道在ui中获取元素索引的方法:重复facelets标签?

代码语言:javascript
运行
复制
<ui:repeat id="topTenGrd" var="dream" value="#{dreamModifyBean.topDreams}">
    <h:outputText class="dream-title uppercase" value="#{dream.number}. #{dream.title}" />
</ui:repeat>
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2011-04-06 14:50:32

指定"varStatus“属性的值:

代码语言:javascript
运行
复制
<ui:repeat id="..." var="..." value="..." varStatus="myVarStatus">

然后,您可以通过EL访问循环索引:

代码语言:javascript
运行
复制
#{myVarStatus.index}

此外,varStatus还可以使用以下属性:

  • 类型的开始整数
  • 类型的结束整数
  • 类型的索引整数类型的步长
  • 布尔类型的偶数
  • boolean
  • first类型的奇数
  • 最后一个布尔类型

有关更多详细信息,请参阅:

https://docs.oracle.com/javaee/7/javaserver-faces-2-2/vdldocs-facelets/ui/repeat.html

票数 96
EN

Stack Overflow用户

发布于 2016-11-14 23:20:41

Brian的回答很好,但我认为它可以更具描述性地描述信息。

我们创建UI:重复

代码语言:javascript
运行
复制
<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

代码语言:javascript
运行
复制
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.中找到

票数 9
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5562214

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档