ClassName

atg.droplet.TableForEach

Component

/atg/dynamo/droplet/TableForEach

The TableForEach servlet bean is an extension of the ForEach servlet bean. TableForEach renders its output parameter in a two-dimensional format, such as a table. The array parameter can be a Collection (Vector, List, or Set), Iterator, Enumeration, Map, Dictionary, or array. The numColumns parameter specifies the number of columns across which to display the array. The elements of the array are arranged across the columns.

The output parameter is rendered for each cell in the table. Note that if the array size is not a multiple of the number of columns, output is rendered with a null element parameter for the remaining columns in the last row. A Switch servlet bean can be used to conditionally fill in the missing items in the row.

Input Parameters

array
Defines the list of items to output. This parameter can be a Collection (Vector, List, or Set), Iterator, Enumeration, Map, Dictionary, or array.

numColumns
Specifies the number of columns across which to display the array.

sortProperties
This optional parameter holds a string that specifies the order the items in the array are rendered. The syntax of this parameter depends on the type of item in the array: JavaBeans, Dynamic Beans, or on Dates, Numbers, or Strings.

To sort on the properties of a JavaBean, specify the value of sortProperties as a comma-separated list of property names. You can sort on as many properties as you like. The first property name specifies the primary sort, the second property name specifies the secondary sort, and so on. Use + followed by a property name to indicate that items in the array should be sorted in ascending order and followed by the property name to indicate descending order.

For example, to sort an array of JavaBeans first by an alphabetical ordering of title and then by descending order of size, use this input parameter:

<dsp:param name="sortProperties" value="+title,size"/>

If your array consists of Dates, Numbers, or Strings, specify the value of sortProperties with either a single + or a single to indicate ascending or descending order respectively.

For example, to sort an output array of Strings in alphabetical order:

<dsp:param name="sortProperties" value="+"/>

When you are sorting elements of a Map, and you want to sort by the key, set the value to the ascending/descending indicator followed by an underscore and the term key:

<dsp:param name="sortProperties" value="_key"/>

When one servlet bean is nested in another and both accept the sortProperties parameter, the child servlet bean inherits the sortProperties setting applied by the enclosing servlet bean unless the child specifies another sortProperties setting or is assigned an empty value:

<dsp:param name="sortProperties" value=""/>

Output Parameters

index
This parameter is set to the zero-based index of the current element of the array each time that the output parameter is rendered. The value of index for the first iteration is 0.

count
This parameter is set to the one-based index of the current element of the array each time that the output parameter is rendered. The value of count for the first iteration is 1.

rowIndex
This parameter is set to the current row index each time one of the output parameters is rendered.

columnIndex
This parameter is set to the current column index each time one of the output parameters is rendered.

key
If the array parameter is a Map or Dictionary, this parameter is set to the value of the key in the Map or Dictionary.

element
This parameter is set to the current element of the array each time that output parameter is rendered. If the array size is not an even multiple of the number of columns, element is set to null for the remaining items in the last row.

Open Parameters

output
This parameter is rendered once for each element in the array.

outputStart
If the array is not empty, this parameter is rendered before any output elements. It can be used to render the heading of a table, for instance.

outputEnd
If the array is not empty, this parameter is rendered after all output elements. It can be used to render text following a table, for instance.

outputRowStart
If the array is not empty, this parameter is rendered once for each row in the output at the beginning of the row. It can be used to render the row heading of a table, for instance.

outputRowEnd
If the array is not empty, this parameter is rendered once for each row in the output at the end of the row. It can be used to render text following a row in a table, for instance.

empty
This optional parameter is rendered if the array contains no elements.

Example

This example displays the values of the initialServices property of the ATG platform’s Initial component. The values are displayed in a two-column table. The outputStart, outputEnd, outputRowStart, and outputRowEnd open parameters define the table formatting.

<dsp:importbean bean="/atg/dynamo/droplet/TableForEach"/>

<dsp:droplet name="TableForEach">
  <dsp:param bean="/Initial.initialServices" name="array"/>
  <dsp:param name="numColumns" value="2"/>
  <dsp:oparam name="outputStart"><table border=1></dsp:oparam>
  <dsp:oparam name="outputEnd"></table></dsp:oparam>
  <dsp:oparam name="outputRowStart"><tr></dsp:oparam>
  <dsp:oparam name="outputRowEnd"></tr></dsp:oparam>
  <dsp:oparam name="output">
    <td>
      <dsp:valueof param="element.absoluteName">&nbsp;</dsp:valueof>
    </td>
  </dsp:oparam>
</dsp:droplet>
 
loading table of contents...