The bean and item-descriptor elements contain one or more filter elements. To filter an item the same way each time, define a single filter. To apply different filters on different occasions, define multiple filters under the bean or item-descriptor with a different filter ID for each.

The filter element contains the following attributes:

Attribute

Description

id

The identifier for the filter when it is referenced by another filter, a default filter setting or another actor.

include-filter

Identifies the filter that is included in the property definition. The inclusion occurs at all levels of the class hierarchy.

default-include

Identifies whether or not to include all of the standard properties when obtaining values for this component. The default is false, where only filtered properties will be included.

Example: Referencing Another Filter Property By ID

You can reference a filter by ID when, for example, you want to return different views of the same object within a single response. The following example shows how the product repository item in the ProductCatalog has a relatedProducts property. However, this example does not want to return all properties of the product item for each related product. This example shows that when a product item is filtered with the summary filter ID, only the repositoryId, displayName and thumbnailImage properties are returned for the relatedProducts property. Also note that the target attribute is used to rename properties:

<bean-filtering>
  <repository name="/atg/commerce/catalog/ProductCatalog">
    <item-descriptor="product" default-filter="full">
      <filter id="detailed">
        <property name="repositoryId" target="id"/>
        <property name="displayName"/>
        <property name="longDescription"/>
        <property name="productDescription" target="description"/>
        <property name="thumbnailImage" target="thumbnailImage.url"/>
        <property name="fullImage" target="fullImage.url"/>
        <property name="largeImage" target="largeImage.url"/>
        <property name="relatedProducts" property-customizer=""
             filter-id="summary"/>
      </filter>
      <!-For related products we only want to output a small set of properties
           about the related products -->
      <filter id="shortSummary">
        <property name="repositoryId" target="id"/>
        <property name="displayName"/>
        <property name="thumbnailImage" target="thumbnailImage.url"/>
      </filter>
    </item-descriptor>
  </repository>

Note that the filter-id attribute of the filter element supersedes any filters that may have been applied in the actor output definition.

Example: Referencing a Filter ID Using an Actor Definition

You can also reference a filter-id by including it within an actor definition. For example, if you wanted to add a summary description to each product contained within a list of product results, apply a specific filter by ID using the actor definition. The following example configures the output element to write to a list of product repository item. The shortSummary filter, which was created in the previous example, will output the repository ID, the display name, and thumbnail image.

<actor-template>
  <actor-chain>
    <component name="/atg/commerce/catalog/ExampleCatalogService"
        method="search" method-return-var="products">
      <output name="products" value="${products}" filter-id="summary" />
    </component>
  </actor-chain>
</actor-template>

To avoid having to duplicate property definitions that are shared among different filter descriptions, you can use the include-filter attribute. This includes properties from another filter. For example, the detailed filter could have been written so that the detailed filter includes the summary filter:

<bean-filtering>
  <repository name="/atg/commerce/catalog/ProductCatalog">
    <item-descriptor="product" default-filter="full">
      <filter id="detailed" include-filter="summary">
        <property name="longDescription"/>
        <property name="productDescription" target="description"/>
        <property name="fullImage" target="fullImage.url"/>
        <property name="largeImage" target="largeImage.url"/>
        <property name="relatedProducts" property-customizer=""
             filter-id="summary"/>
      </filter>
      <!-For related products we only want to output a small set of properties
           about the related products -->
      <filter id="shortSummary">
        <property name="repositoryId" target="id"/>
        <property name="displayName"/>
        <property name="thumbnailImage" target="thumbnailImage.url"/>
      </filter>
    </item-descriptor>
  </repository>

In this example, the repositoryId, displayName and thumbnailImage properties are not listed in the detailed filter, but will still be included because the full filter now includes the summary filter using the filter-include attribute. Note that if a property is defined in both of the filters, the detailed filter will override the summary filter when rendering.


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