Performs a targeting operation and displays the first specified number of items returned by the targeter.

Class Name

atg.targeting.

Component

/atg/targeting/TargetingFirst

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

howMany

The number of items to display. If howMany is greater than the number of items returned by the targeting operation, TargetingFirst renders the number of items available. If you omit this parameter, only the first item is displayed.

sortProperties

The display order of 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.

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 the fireContentEvent 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 zero-based index of the current target item each time the output parameter is rendered. The value for the first loop iteration is 0.

count

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

element

Each time the output parameter is rendered, set to the next item taken from the array returned by the targeting operation.

empty

Rendered if the targeting operation returns no matching items.

Open Parameters

output

Rendered once for each element in the subset of the array of targeting results, as specified by the howMany parameter.

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

TargetingFirst takes the results of the targeting operation and displays the first n items returned, where n is the number of items specified by the howMany parameter. The targeter component used for the targeting operation is set by the targeter and sourceMap input parameters. On each iteration, the output parameter element is set to the next item in the resulting array of target objects. If the targeting rules contain sorting directives, TargetingFirst can return the best howMany matches among the resulting target objects.

Example

The following example displays the first 10 ski resorts in the targeting result set, because the value of its howMany parameter is set to 10. For each resort, the JSP containing this targeting servlet bean displays the name (in a hypertext link) and an image. The sortProperties parameter specifies that the resorts should be listed alphabetically by their displayName property.

<%-- displays the first 10 ski resorts in the targeting result set --%>

<dsp:droplet name="/atg/targeting/TargetingFirst">
  <dsp:param=
  "bean:/atg/registry/repositorytargeters/targetedcontent/skiresorttargeter"
  name="targeter" value="\">
  <dsp:param name="howMany" value="10">
  <dsp:param name="sortProperties" value="+displayName">
  <dsp:oparam name="output">
     <dsp:getvalueof var="a11" param="element.URL" vartype="java.lang.String">
        <dsp:a href="${a11}">
           <dsp:valueof param="element.displayName"/>
        </dsp:a>
     </dsp:getvalueof>
     <dsp:getvalueof var="img18" param="element.image"
     vartype="java.lang.String">
        <dsp:img src="${img18}">
     </dsp:getvalueof>
    <p>
  </dsp:oparam>
</dsp:droplet>

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

Legal Notices