Oracle ADF Faces - af:forEach
Summary

Tag name: < af:forEach >

The forEach tag is a replacement for the JSTL < c:forEach > tag that works with ADF Faces components. Today, < c:forEach > cannot be used with any JSF components or tags. This tag brings that functionality to JSF, but it is limited to ADF Faces tags. This tag also has several limitations not found in < c:forEach > :

  • < af:forEach > does not currently support scenarios where the size of the "items" list or array changes from one request to the next. It may be possible to work around this in specific scenarios by manually deleting all children of the parent component ( < af:selectOneListbox > in the above example), but this has not yet been tested.
  • < af:forEach > does not support arbitrary java.util.Collections; it can only iterate over java.util.Lists or arrays.
  • < af:forEach > executes at the time the JSP tag executes. So it does not have access to any EL variables that are created by JSF components. For example, the < af:table > creates an EL variable using the value of the "var" attribute. However, this EL variable is not available to < af:forEach >

Example:

            <af:selectOneListbox value="#{someValue}">
              <af:forEach var="item" items="#{model.listOfItems}">
                <af:selectItem value="#{item.value}" text="#{item.text}"/>
              </af:forEach>
            </af:selectOneListbox>
            <af:forEach varStatus="vs" begin="1" end="5">
              <af:outputText id="ot2" value="#{vs.index} #{vs.count} #{vs.begin} #{vs.current}"/>
            </af:forEach>

Attributes
Name Type Supports EL? Description
begin int No i ndex at which iteration begins
end int No index at which iteration ends
items Object Only EL the collection to iterate over
step int No number to increment on each iteration
var String No name of the variable exposed when iterating
varStatus String No name of the loop status exposed when iterating. The properties 'index','count','begin','end','step','current','first','last' are available through this
Copyright © 2003-2006, Oracle Corporation. All Rights Reserved.

E-mail this page
Printer View Printer View
Oracle Is The Information Company About Oracle | Oracle RSS Feeds | Careers | Contact Us | Site Maps | Legal Notices | Terms of Use | Privacy