Facelets 重复标签索引 [英] Facelets repeat Tag Index

查看:23
本文介绍了Facelets 重复标签索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有谁知道在 ui:repeat facelets 标签中获取元素索引的方法吗?

Does anyone know a way to get the index of the element in a ui:repeat facelets tag?

<ui:repeat id="topTenGrd" var="dream" value="#{dreamModifyBean.topDreams}">
    <h:outputText class="dream-title uppercase" value="#{dream.number}. #{dream.title}" />
</ui:repeat>

推荐答案

为varStatus"属性指定一个值:

Specify a value for the "varStatus" attribute:

<ui:repeat id="..." var="..." value="..." varStatus="myVarStatus">

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

You can then access the loop index via EL:

#{myVarStatus.index}

此外,以下属性可用于 varStatus:

Additionally, the following properties are available to the varStatus:

  • 整数类型的开始
  • 整数类型结束
  • int 类型的索引
  • 整数类型的步骤
  • 即使是布尔类型的
  • 布尔类型的奇数
  • 第一个布尔类型
  • 最后一个布尔类型

更多详情,请参见:

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

这篇关于Facelets 重复标签索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆