Displays a subset of the elements of an array, arranging the output in a two-dimensional format.

Class Name

atg.droplet.TableRange

Component

/atg/dynamo/droplet/TableRange

Required 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.

howMany

The number of array elements to display. If howMany is greater than the number of array elements, TableRange renders the number of elements available.

numColumns

The number of columns used to display the array. If 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.

Optional Input Parameters

start

The initial array element, where a setting of 1 (the default) specifies the array’s first element. If start is greater than the number of elements in the array, the empty parameter (if specified) is rendered.

sortProperties

Holds a string that specifies the order to render array items. The syntax of this parameter depends on the array item type: JavaBean, Dynamic Bean, Date, Number, or String.

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 an unlimited number of properties, where the first property name specifies the primary sort, the second property name specifies the secondary sort, and so on. To specify ascending sort order, prepend the property name with a plus + sign; to specify descending order, prepend with a minus - sign.

For example, the following input parameter specifies to sort an array of JavaBeans alphabetically by title, then in descending order of size:

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

If the array contains Dates, Numbers, or Strings, prepend the sortProperties value with a plus + or minus sign to specify ascending or descending sort order.

The following example sorts an output array of Strings in alphabetical order:

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

In order to sort Map elements by key, set the value as follows:

{+|-}_key

For example:

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

A nested servlet bean inherits the parent servlet bean’s sortProperties setting, unless the nested servlet bean has its own sortProperties setting. For example, the following setting negates any parent sortProperties setting:

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

Output Parameters

index

Set to the zero-based index of the current array element each time the output parameter is rendered. For example, if start is set to 1, the value of index for the first iteration is 0.

count

Set to the one-based index of the current array element each time 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, set to the Map or Dictionary key.

rowIndex

Set to the current row index each time an output parameter is rendered.

columnIndex

Set to the current column index each time an output parameter is rendered.

element

Set to the current array element each time the index increments and the output parameter is rendered.

hasPrev

Set to true before any output parameters are rendered, indicates whether the array includes any items that precede the current array set.

prevStart

Set before any output parameters are rendered, and only if hasPrev is true, 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

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

prevHowMany

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

hasNext

Set to true before any output parameters are rendered, indicates whether the array includes any items that follow the current array set.

nextStart

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

nextEnd

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

nextHowMany

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

Open Parameters

output

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, rendered before any output elements. For example, this parameter can be used to render a heading.

outputEnd

If the array is not empty, rendered after all output elements. For example, this parameter can be used to render a footer.

outputRowStart

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

outputRowEnd

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

empty

Rendered if the array or the specified subset of the array contains no elements.

Usage Notes

TableRange 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. When the howMany and numColumns parameters are equal, the table displays one element in each table column.

Example

The following example displays the values of the initialServices property of the 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"
          vartype="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"
          vartype="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>

Copyright © 1997, 2015 Oracle and/or its affiliates. All rights reserved. Legal Notices