ATG Personalization has two ways to sort the results of a targeting operation:

It might be desirable to specify sorting in both places. For example, a targeter can retrieve the first five matching items in order of publication date, then sort publications by author as follows:

The tags for the servlet bean might look like this:

<dsp:droplet name="/atg/targeting/TargetingFirst">
  <dsp:param name="targeter"
   bean="/atg/registry/RepositoryTargeters/Features/AllFeatures"/>
  <dsp:param name="howMany" value="5"/>
  <dsp:param name="sortProperties" value="+author"/>
  <dsp:oparam name="outputStart"> <ul></dsp:oparm>
  <dsp:oparam name="output">
    <li><dsp:valueof param="element.headline"/></li>
  </dsp:oparam>
  <dsp:oparam name="outputEnd"> </ul></dsp:oparm>
</dsp:droplet>

You can set the value of the sortProperties parameter to a string that specifies how to sort the list of items in the output array. Sorting can be performed on JavaBean and Dynamic Bean properties, and on Dates, Numbers, and Strings.

Sorting on JavaBeans and Dynamic Beans

To sort on JavaBean and Dynamic Bean properties, specify the value of sortProperties as a comma-separated list of property names, as follows:

<dsp:param name="sortProperties" value="{+|}property-name[,...]"/

The first instance of property-name specifies the primary sort, the second specifies the secondary sort, and so on. Each property name is prepended by a plus (+) or minus () sign to indicate whether to sort in ascending or descending order.

The following example specifies to sort an output array of JavaBeans by its title property in ascending order, then by its size property in descending order:

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

Sorting on Dates, Numbers and Strings

To sort on Dates, Numbers, and Strings, set sortProperties to a + (ascending) or (descending) sign, as in the following example, which sorts an output array of Strings in alphabetical order:

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

Sorting on a Map key

In order to sort elements of a Map, set sortProperties to the Map key as follows:

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

 
loading table of contents...