Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
446 views
in Technique[技术] by (71.8m points)

jsf - Facelets repeat Tag Index

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>
question from:https://stackoverflow.com/questions/5562214/facelets-repeat-tag-index

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Specify a value for the "varStatus" attribute:

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

You can then access the loop index via EL:

#{myVarStatus.index}

Additionally, the following properties are available to the varStatus:

  • begin of type Integer
  • end of type Integer
  • index of type int
  • step of type Integer
  • even of type boolean
  • odd of type boolean
  • first of type boolean
  • last of type boolean

For more details, see:

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...