|
Basic JSF Features

|
|
The repeat define loop that controls the rendering of a repeat region. A collection is also defined, a member object of which is presented in every iteration of the loop.
The definition aspects is as discussed under the topic of the behavior-define section.
The loop aspect is illustrated with the JSTL tag below. This is for illustration, the appropriateness of this tag for JSF is limited, this owing to the component tree arrangement.
<c:forEach items=="#{books}"
var="i" begin="1" end="20" step="1" varStatus ="status"<
| define-id | var |
| value:O | begin |
| value:N | end |
| value:Step | step |
| data-source | items |
The common use of repeat region is to render tabular list, to satisfy this need, JSF provide the dataTable component, which includes a repeat region internally. See the component type description for more information on dataTable.
More details are available in the attributes descriptions
type
id
data-source
value
define-id
define-class
define-scope
|
SEAM Enhancements
The c:forEach tag that requires caution when used in JSF with JSP, does not carry such cautionary note when used with Seam and Facelets. The underlying Facelet understand component assembly, whereas JSP does not.
Nonetheles, the ui:repeat component is preferred for usage almost always instead of the c:forEach to iterate over content with JSF.
One advantage this component brings, is the repeat region that does not have in-build template. Other repeat components, like dataTable have in-built table structure, whereas this component allows more flexibilities. Example is shown below.
...
<dl>
<ui:repeat value="#{faculty.departments}" var="dept">
<dt>#{dept.name}</dt>
<ui:repeat value="#{dept.students}" var="stud">
<dd>#{ stud.lastName}, #{ stud.firstName}</dd>
</ui:repeat>
</ui:repeat>
</dl>
...
|