Performs a targeting operation and randomly selects and displays n items returned by the targeter, where n is a number you specify.

Class Name

atg.targeting.TargetingRandom

Component

/atg/targeting/TargetingRandom

Required Input Parameters

targeter

The targeter service that performs the targeting operation; 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; an instance of a class that implements the ItemFilter interface, such as atg.targeting.conflict.TopicHistoryConflictFilter.

sourceMap

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

howMany

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

fireViewItemEvent

Specifies whether to trigger a JMS view item event when a page is accessed. The default is true. To prevent the Oracle Commerce 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 Oracle Commerce Platform from firing these two events, set this parameter to false.

Note: Instead of this parameter, you should use the fireViewItemEvent 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 Oracle Commerce Platform from firing these two events, set this parameter to false.

Note: Instead of this parameter, use the fireViewItemEvent parameter.

Output Parameters

index

Set to the current index 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 an item randomly picked from the array returned by the targeting operation.

Open Parameters

output

Rendered once for each element randomly selected from 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

TargetingRandom takes the results of the targeting operation and displays a random selection of the items returned. The number of items displayed is set by the howMany parameter (the default is 1). The targeter component used for the targeting operation is set by the targeter and sourceMap input parameters. On each iteration, the element parameter is set to an item randomly selected from the resulting array of target objects.

Example

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

<%-- displays 10 ski resorts randomly selected from the result set --%>

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

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