Performs a targeting operation and displays all items returned by the targeter.

Class Name

atg.targeting.

Component

/atg/targeting/TargetingForEach

Required Input Parameters

targeter

The targeter service that performs the targeting operation; must be an instance of a class that implements the Targeter interface, such as atg.targeting.DynamicContentTargeter.

Optional Input Parameters

filter

A filter service that filters the items returned by the targeter before they are output; must be an instance of a class that implements the ItemFilter interface, such as atg.targeting.conflict.TopicHistoryConflictFilter.

sourceMap

Represents a mapping between names of source objects associated with a targeting operation and their values; must be an instance of atg.targeting.TargetingSourceMap. If this parameter is omitted, the source Map specified by the servlet bean’s defaultSourceMap property is used. (By default, the value of this property is /atg/targeting/TargetingSourceMap.)

sortProperties

The order to display result set elements. See Sorting Results in the Serving Targeted Content with ATG Servlet Beans chapter for information about how to specify this parameter, and for information about the relationship between targeter sorting and servlet bean sorting. Because TargetingForEach displays all targeting results, the sort order, if present, overrides the targeter’s sort order unless you set the maxNumber property to limit the number of results returned.

maxNumber

If the maxNumber property is set, the targeter only returns at most maxNumber items in the targeting result set. Use this property to prevent loading potentially large result sets into memory.

fireViewItemEvent

Specifies whether to trigger a JMS view item event when a page is accessed. The default is true. To prevent the ATG platform from firing a view item event, set this parameter to false.

fireContentEvent

Specifies whether to trigger an event when a page is accessed. If set to true or omitted, a JMS view event fires; if the accessed page is a Content repository item, a content viewed event also fires. To prevent the ATG platform from firing these two events, set this parameter to false.

Note: Use the fireViewItemEvent parameter instead of this parameter.

fireContentTypeEvent

Specifies whether to trigger an event when a page is accessed. If set to true or omitted, a JMS view event fires; if the accessed page is a Content repository item, a content type event also fires. To prevent the ATG platform from firing these two events, set this parameter to false.

Note: Use the fireViewItemEvent parameter instead of this parameter.

Output Parameters

index

Set to the index of the current array element returned by the targeter service each time the index increments and the output parameter is rendered.

count

Set to the index plus one. The value for the first loop iteration is 1.

element

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

Open Parameters

output

Rendered once for each element in the array of targeting results.

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.

empty

Rendered if the results array contains no elements.

Usage Notes

TargetingForEach is a specialized version of the ForEach servlet bean; it performs a targeting operation using the targeter component set by its targeter and sourceMap parameters. TargetingForEach displays every item returned by the targeting operation in the manner specified by its output parameter.

Example

The following example displays all ski resorts returned in the targeting result set. For each resort, the JSP containing this servlet bean displays the name (in a hypertext link) and an image.

<%-- displays all the ski resorts in the result set --%>
<dsp:droplet name="/atg/targeting/TargetingForEach">
  <dsp:param
  bean="/atg/registry/repositorytargeters/targetedcontent/skiresorttargeter"
  name="targeter"/>
  <dsp:oparam name="output">
    <dsp:getvalueof var="a7" param="element.URL" vartype="java.lang.String">
      <dsp:a href="${a7}">
        <dsp:valueof param="element.displayName"/>
      </dsp:a>
    </dsp:getvalueof>
    <dsp:getvalueof var="img14" param="element.image"
    vartype="java.lang.String">
      <dsp:img src="${img14}"/>
    </dsp:getvalueof>
    <p>
  </dsp:oparam>
</dsp:droplet>

Copyright © 1997, 2012 Oracle and/or its affiliates. All rights reserved.

Legal Notices