forEach JavaServer Page tag |
Use the forEach tag to repeat an action for each property in a page, for each page in a Page List
, or for each property in any list or group. B-24365
In runtime stream processing that includes a section or control that includes complex parameters on the Parameters tab, you can use the forEach tag to iterate over arrays or groups of parameter values. PROJ-1128 5.4
Basics
Properties with a mode other than Single Value
are known as aggregates. The forEach tag iterates through the parts of an aggregate property.
For example, assume a clipboard page named Operators contains embedded pxResults()
pages. The pxResults()
pages each hold a property pyUserIdentifier identifying one customer. Use the forEach tag to create an HTML table that contains a row for each customer: PICAD 12/1/06
<TABLE>
<pega:forEach name="Operators.pxResults">
<TR><TD>
<pega:reference name="$THIS.pyUserIdentifier" />
</TD></TR>
</pega:forEach >
</TABLE>
Within the scope of the forEach tag, special keywords are available:
Complete syntax
In the syntax presentations below:
[
and ]
define optional parts of the tag. Do not type the brackets.<pega..>
and </pega...>
mark the start and end of the tag.To do something for each property in a Value List
, Value Group
, Page
, Page List
, or Page Group
, use this syntax. In place of the word aggregate-reference, enter the name of the aggregate property.
<pega:forEach name="aggregate-reference" >
actionToRepeat or
</pega:forEach >
Attribute |
Description |
name
|
The name of the aggregate property, $this , or $this .propertyname. To refer to a complex parameter, use the keyword "param" followed by the complex parameter name. |
To do some processing for each property in a top-level page, use this syntax:
<pega:forEach name="page-name" >
actionToRepeat
</pega:forEach >
If the array contains only Single Value
properties, use the keyword $this
:
<pega:forEach name="$this">
actionToRepeat
</pega:forEach >
No conditional "break" or "leave" from the scope of a forEach tag is available: all iterations always occur. To perform only some, rather than all, iterations of a forEach tag, include a <pega:when > element: GARFJ SharePoint 12/12/08
<pega:forEach name="page-name" >
<pega:when ...>
actionToRepeat if true
</pega:when>
</pega:forEach >
Nesting a forEach tag within the scope of another forEach tag is supported. B-21590
To iterate over complex parameters that are similar in structure to Value List
, Value Group
, Page List
, and Page Group
properties defined on the Parameters tab of a section or control rule:
<pega:forEach name="Param.MyPageList" >
<pega:reference name="$this.Innervalue"/>
</pega:forEach>
Examples
These examples use the forEach tag to display values from clipboard pages.
If the array contains lists of pages, then you can embed a forEach tag and iterate over that list as well:
<pega:forEach name=”.pxResults”>
<pega:forEach name=”$this.addresses”>
<pega:reference name=”$this.streetName”/>
</pega:forEach>
</pega:forEach>
To obtain values from an embedded group of pages:
<pega:forEach name=".pxFlow" >
value="<pega:reference ref="$this.pxAssignmentKey" /> "
</pega:forEach >
This example uses the Work-.pxFlow property, a Page Group
. It identifies, in sequence, the value of the pxAssignmentKey property for each page in the Page Group
.
To create a selection box, use syntax similar to the following: PICAD 12/8/06
<select name="<p:r n="$this-name" /> ">
<pega:forEach name=".pyKeyDefList" >
<option value="<pega:reference ref="$this.pyKeyName" />">
<pega:reference ref="$this.pyKeyCaption" >
</pega:forEach >
</select>
To create option (radio) buttons, use syntax similar to the following:
<pega:withTarget name="$this" >
<pega:forEach name=" .pyKeyDefList" >
<input type="radio" value="<pega:reference
ref="$this.pyKeyName" / >">
<pega:reference ref="$this.pyKeyCaption" / >
</pega:forEach>
</pega:withTarget>
An example of iteration over complex parameter values rather than property values: Proj-1128
<pega:forEach name="Param.MyPageList">
<pega:withEmbedded name="$this" >
<pega:reference name=".MyInnerValue" />
</pega:withEmbedded>
</pega:forEach>