ClassName

atg.targeting.TargetingForEach

Component

/atg/targeting/TargetingForEach

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

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.

filter
Specifies an optional 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
Specifies 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 sorting performed by the targeter and sorting performed by the servlet bean. Because TargetingForEach displays all of the 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. You can use this property as a precaution to prevent loading potentially large result sets into memory.

fireViewItemEvent
Indicates whether to trigger a JMS view item event when a page is accessed. Default is true, so an event is fired if this parameter is omitted. To prevent the ATG platform from firing a view item event, set this parameter to false.

fireContentEvent
Indicates whether to trigger an even when a page is accessed. By setting this parameter to true or omitting it, you cause a JMS view event to fire, and when the accessed page is an item in a Content repository, a content viewed event also fires. To prevent the ATG platform from firing these two events, set this parameter to false. It is recommended that you use the fireViewItemEvent parameter instead of the fireContentEvent parameter.

fireContentTypeEvent
Indicates whether to trigger an even when a page is accessed. By setting this parameter to true or omitting it, you cause a JMS view event to fire, and when the accessed page is an item in a Content repository, a content type event also fires. To prevent the ATG platform from firing these two events, set this parameter to false. It is recommended that you use the fireViewItemEvent parameter instead of the fireContentTypeEvent parameter.

Output Parameters

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

count
This parameter is set to the index+ 1. Its value for the first iteration of the loop is 1.

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

Open Parameters

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

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.

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

Example

This example displays all of the 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 id="img14" param="element.image"
    idtype="java.lang.String">
      <dsp:img src="${img14}"/>
    </dsp:getvalueof>
    <p>
  </dsp:oparam>
</dsp:droplet>
 
loading table of contents...