ClassName |
|
---|---|
Component |
|
The TargetingRandom
servlet bean 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. At each iteration, the element
parameter is set to an item randomly selected from the resulting array of target objects.
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
.)
howMany
If specified, indicates the maximum number of target items to display. If the number of items returned by the targeting operation is smaller than the howMany
parameter, only that many items are displayed. The default value of howMany
is 1; if you do not specify a value of this parameter, only one item is displayed.
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 current index each time the output
parameter is rendered. Its value for the first iteration of the loop is 0.
count
This parameter is set to the index
+
1. Its value for the first iteration of the loop is 1.
element
Each time the output
parameter is rendered, this parameter is set to an item randomly picked from the array returned by the targeting operation.
Open Parameters
output
This parameter is rendered once for each element
randomly selected from 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 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" idtype="java.lang.String"> <dsp:img src="${img16}"/> </dsp:getvalueof> <p> </dsp:oparam> </dsp:droplet>