ClassName

atg.droplet.TableRange

Component

/atg/dynamo/droplet/TableRange

The TableRange servlet bean combines the functions of the Range and TableForEach servlet beans. Like TableForEach, TableRange renders its output parameter in a two-dimensional format, such as a table. Like Range, TableRange renders a subset of the output array. The array parameter can be a Vector, Enumeration, Dictionary, or array.

TableRange renders its output parameter for each element in its array parameter, beginning with the array element that corresponds to the start parameter and continuing until it has rendered a number of elements equal to the howMany parameter. The resultant table displays, when the howMany parameter and the numColumns parameter are equal, one element in each table column.

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.

start
Specifies which element of the array to start with. Setting start=1 renders the array beginning with its first element. If start is greater than the number of elements in the array and the empty output parameter is supplied in your implementation, the empty parameter is rendered.

howMany
Specifies the number of items in the array to display. If the combination of start and howMany points past the end of the array, Range stops rendering when the end of the array is reached.

numColumns
Specifies the number of columns across which to display the array. When you specify more columns than elements (numColumns is greater than howMany), the additional columns display empty. In the reverse situation, (numColumns is fewer than howMany), the excess elements display in a second row.

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. For example, if start is set to 1, 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. For example, if start is set to 1, the value of count for the first iteration is 1.

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.

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.

element
This parameter is set to the current element of the array each time that the index increments and the output parameter is rendered.

hasPrev
This parameter is set to true before any of the output parameters are rendered. It indicates whether the array includes any items that precede the current array set.

prevStart
This parameter is set before any of the output parameters are rendered, and only if hasPrev is true. It indicates the value of start that should be used to display the previous array set. You can use this parameter to create a link or form submission that displays the previous elements of the array.

prevEnd
This parameter is set before any of the output parameters are rendered, and only if hasPrev is true. It indicates the (1-based) count of the last element in the previous array set.

prevHowMany
This parameter is set before any of the output parameters are rendered, and only if hasPrev is true. It indicates the number of elements in the previous array set.

hasNext
This parameter is set to true before any of the output parameters are rendered. It indicates whether the array includes any items that follow the current array set.

nextStart
This parameter is set before any of the output parameters are rendered, and only if hasNext is true. It indicates the value of start that should be used to display the next array set.

nextEnd
This parameter is set before any of the output parameters are rendered, and only if hasNext is true. It indicates the (1-based) count of the last element in the next array set.

nextHowMany
This parameter is set before any of the output parameters are rendered, and only if hasNext is true. It indicates the number of elements in the next array set.

Open Parameters

output
This parameter is rendered once for each element in the subset of the array defined by the start and howMany parameters.

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

outputEnd
If the array is not empty, this parameter is rendered after all output elements. It can be used to render a footer, 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 or the specified subset of the array contains no elements.

Example

This example displays the values of the initialServices property of ATG’s Initial component. The values are displayed in a two-column table, 2 at a time. This example uses a Switch servlet bean to create navigational links after each 2 values. If there are values in the array that precede the ones currently displayed, there is a link to the previous values. If there are values in the array that follow the ones currently displayed, there is a link to the next set of values.

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

<dsp:droplet name="TableRange">
  <dsp:param bean="/Initial.initialServices" name="array"/>
  <dsp:param name="numColumns" value="2"/>
  <dsp:param name="howMany" value="2"/>
  <dsp:oparam name="outputStart">
  <table border=1></dsp:oparam>
  <dsp:oparam name="outputEnd">
    <tr><td colspan=2>
      <dsp:droplet name="Switch">
        <dsp:param name="value" param="hasPrev"/>
        <dsp:oparam name="true">
          <dsp:getvalueof var="a27" bean="/OriginatingRequest.pathInfo"
          idtype="java.lang.String">
            <dsp:a href="${a27}">
              <dsp:param name="start" param="prevStart"/>
              Previous <dsp:valueof param="prevHowMany"/>
            </dsp:a>
          </dsp:getvalueof>
        </dsp:oparam>
      </dsp:droplet>
      &nbsp;
      <dsp:droplet name="Switch">
        <dsp:param name="value" param="hasNext"/>
        <dsp:oparam name="true">
          <dsp:getvalueof var="a46" bean="/OriginatingRequest.pathInfo"
          idtype="java.lang.String">
            <dsp:a href="${a46}">
              <dsp:param name="start" param="nextStart"/>
              Next <dsp:valueof param="nextHowMany"/>
            </dsp:a>
          </dsp:getvalueof>
       </dsp:oparam>
      </dsp:droplet>
    </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...