Displays a single output the number of times specified.

Class Name

atg.droplet.For

Component

/atg/dynamo/droplet/For

Required Input Parameters

howMany

The number of times to render the output parameter.

Output Parameters

index

The zero-based index of the current array element, incremented each time the output parameter is rendered.

count

The one-based index of the current array element, incremented each time the output parameter is rendered.

Open Parameters

output

Rendered the number of times specified by the howMany parameter.

Usage Notes

The servlet bean For loops the number of times specified by the input parameter. Given an integer parameter howMany, For renders its output parameter that many times. The howMany parameter must be a String representation of an int. Each iteration sets the index parameter to the current loop count, starting at 0, and sets the count parameter to index plus one, starting at 1.

Example

In the following example, the user is presented with textboxes, the number of which is user-determined. On the first page (code not shown) the user specifies how the number of text boxes to be shown. This value is stored in the form’s numChoices property. On the second page (code excerpt included below), the For servlet bean displays the user-specified number of text boxes by setting its howMany input parameter from the numChoices property. The servlet bean uses the count parameter to supply a consecutive number to each text box. When a user enters values into the text boxes, those values are saved to the form’s choice property.

<dsp:droplet name="/atg/dynamo/droplet/For">
  <dsp:param name="howMany" bean="SomeForm.numchoices"/>
  <dsp:oparam name="output">
      Text box # <dsp:valueof param="count"/>:
      <dsp:input bean="SomeForm.choice[param:index]" type="text"/>
    <br/>
  </dsp:oparam>
</dsp:droplet>