Application Platform 10.7 | Application Platform API | webMethods Tag Library for JSP | <webm:loop>
 
<webm:loop>
Use the <webm:loop> tag to execute a block of code once for each element in a specified Document, Document List, or String List in the Integration Server pipeline.
If you do not specify a Document, Document List, or String List to loop over, Integration Server will loop over the entire pipeline.
You can use the <webm:loopsep> tag to insert a specified character sequence between the results from the <webm:loop> tag in the HTML page produced from the JSP. <webm:loopsep> does not insert the character sequence after the result produced by the last loop iteration.
At run time, Integration Server loops over the pipeline data. The following table describes the Integration Server loop for each data structure.
For this data structure
Integration Server loops over
Pipeline
Each key in the pipeline.
Document
Each key in the Document.
Document List
Each Document in the Document List.
String List
Each String in the String List.
Syntax
For the pipeline:
<webm:loop loopStruct="true" [excludePrivate="true"]>
block_of_code
[<webm:loopsep sepString="separator_string"/>]
</webm:loop>
For a Document:
<webm:loop variable="loop_variable" loopStruct="true" [excludePrivate="true"]>
block_of_code
[<webm:loopsep sepString="separator_string"/>]
</webm:loop>
For a Document List or String List:
<webm:loop variable="loop_variable" [loopStruct="true"]>
block_of_code
[<webm:loopsep sepString="separator_string"/>]
</webm:loop>
Arguments
Argument
Description
[variable="l oop_variable"]
Document, Document List, or String List to loop over. If you omit this option, Integration Server loops over the entire pipeline.
Example
<webm:loop variable="items">
[loopStruct="true"]
Sets Integration Server to loop over each key in the pipeline, Document, Document List, or String List.
Example
<webm:loop variable="items" loopStruct="true">
[excludePrivate="true"]
Sets Integration Server to skip keys with names starting with $.
Example
<webm:loop variable="items"
excludePrivate="true">
Usage Notes
*To access the names of the keys dynamically in the structure over which you are looping when you are using [loopStruct="true"], use the predefined $key keyword.
*If you are using [loopStruct="true"] for nested loops and the outer loop is looping over a structure with dynamic contents and you require the inner loop to loop over the keys in the current key of the outer loop, set variable in the inner loop to #$key keyword. In most cases this keyword is used to process a set of Documents contained within another Document. See the Examples section.
Examples
*To add shipping information for each Document from Document List items in the HTML page produced from the JSP:
<p>This shipment contains the following items:</p>
<webm:loop variable="items">
<p>
<webm:value variable="qty"/>
<webm:value variable="stockNum"/>
<webm:value variable="description"/>
<webm:value variable="status"/>
</p>
</webm:loop>
*To list each element from the String List backItems on separate lines in the HTML page and indicate that the elements are backordered:
<p>The following items are backordered</p>
<p>
<webm:loop variable="backitems">
<webm:value/><BR>
</webm:loop>
</p>
*To list the elements in the String List backItems with commas between each elements and indicate that the elements are backordered:
<p>The following items are backordered</p>
<p>
<webm:loop variable="backitems">
<webm:value/>
<webm:loopsep sepString=","/>
</webm:loop>
</p>
*To display the names and values of the keys in the Integration Server pipeline on the HTML page:
<webm:loop loopStruct="true">
<webm:value variable="$key"/><br>
<webm:value/><br>
</webm:loop>
*To loop over the keys in the Document named Addresses which contents are not known before run-time and insert each name and its associated address into the HTML page produced from the JSP:
<p>Customer Addresses:</p>
<p>
<webm:loop variable="Addresses" loopStruct="true">
<webm:value variable="$key"/>
<webm:loop variable="#$key" loopStruct="true">
<webm:value variable="streetAddr1"/>
<webm:value variable="streetAddr2"/>
<webm:value variable="city"/>
<webm:value variable="state"/>
<webm:value variable="postalCode"/>
</webm:loop>
</webm:loop>
</p>
The following table shows the structure and key-value pairs used in the Document for the current example:
Key
Value
Global Sporting Goods, Inc.
Key
Value
streetAddr1
10211 Brookpark Road
streetAddr2
city
Cleveland
state
OH
postalCode
22130
Fitness Shoes
Key
Value
streetAddr1
2549 Oak Avenue
streetAddr2
city
Silver Spring
state
MD
postalCode
20905
Yoga Wear
Key
Value
streetAddr1
6666 Maple Street
streetAddr2
Suite 100
city
New York
state
NY
postalCode
11302