This example describes how a collection filter limits the contents in a slot using a scenario. Consider a Web site that provides articles about various topics. To ensure that only current articles are displayed to users, each article has a start and end date property. Articles that are active on the current day are added to a slot.

This diagram is described in surrounding text

The scenario begins with an event that adds all News RepositoryItems to the Articles slot. The next action, Filter Slot Contents, passes the items in Articles to StartEndDateFilter. To learn more about this action, see Filter Slot Contents Action.

Rather than use a scenario to filter a slot, you can use a JSP to access a filled slot and filter the contents within it. The StartEndDateFilterDroplet accesses the StartEndDateFilter component, which performs the filtering task and adds the resultant collection to the Articles slot:

<dsp:droplet name="/atg/collections/filter/droplet/StartEndDateDroplet">
   <dsp:param name="collection" beanvalue="Articles"/>
   <dsp:param name="collectionIdentifierKey" value="date"/>

   <dsp:oparam name="output">
      Featured Articles:<p>
      <dsp:droplet name="/atg/targeting/TargetingForEach">
         <dsp:param bean="/atg/registry/Slots/Articles" name="targeter"/>
         <dsp:oparam name="output">
            <dsp:valueof param="filteredCollection"/>
         </dsp:oparam>
      </dsp:droplet>
   </dsp:oparam>

   <dsp:oparam name="empty">
      There are no articles today.
   </dsp:oparam>
</dsp:droplet>

Each article has a start and end date, which StartEndDateFilter compares to the current date. All articles that are “started” and have not yet “ended” remain in the slot. All others are removed by the filter from the slot.


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