In many cases, when you display a facet value on a page, it is desirable to reformat the value, because the format used to store the values in the index is not optimized for display purposes. For example:
Boolean values are stored in the index as 0 (false) or 1 (true).
Dates are encoded as long integers.
Price data is stored as raw numbers with no currency symbol or other formatting. For example, the value representing $87,109.00 might be stored in the index as 87109.0.
To reformat these values for displaying on pages, the Oracle ATG Web Commerce platform includes a servlet bean, atg.repository.search.refinement.RefinementValueDroplet. This servlet bean takes as input a facet selection value and the repository ID of the refinementElement that represents the facet, and outputs the value in a more human-readable form.
Oracle ATG Web Commerce includes a component of this class, which you can use in your pages like this:
<dsp:droplet name="/atg/commerce/search/refinement/RefinementValueDroplet">
<dsp:param name="refinementId" value="${facetHolder.facet.id}"/>
<dsp:param name="refinementValue" value="${facetValueNode.facetValue.value}"/>
<dsp:oparam name="output">
<dsp:valueof param="displayValue"/>
</dsp:oparam>
</dsp:droplet>To perform the formatting, RefinementValueDroplet uses a class that implements the atg.repository.search.MetaPropertyValueFormatter interface. By default, this class is atg.repository.search.DefaultMetaPropertyValueFormatter. The RefinementValueDroplet component has a defaultValueFormatter property that points to a component of this class, /atg/commerce/search/refinement/DefaultMetaPropertyValueFormatter.
DefaultMetaPropertyValueFormatter can reformat a variety of data types:
For a repository ID property (e.g.,
childSKUs.$repositoryId), it returns the item display name.For a date property (e.g.,
creationDate), it returns a locale-specific date string.For an enumerated property (e.g.
stockAvailabilityStatus), it returns the display name of the enumerated value.For a Boolean property (e.g.,
onSale) it looks in a resource bundle for a key of the formatproperty-name_0(forfalse) orproperty-name_1(fortrue), and returns the string associated with that key. For example, for anonSaleproperty, the keys would beonSale_0andonSale_1. If the key is not found, the value is returned unchanged. The resource bundle is specified by theresourceBundleproperty of theDefaultMetaPropertyValueFormattercomponent.
You can write a custom implementation of the MetaPropertyValueFormatter interface to use for specific faceting properties. Oracle ATG Web Commerce includes one such class, atg.commerce.search.PriceMetaPropertyValueFormatter, for formatting price data. It also includes a component of this class, /atg/commerce/search/PriceMetaPropertyValueFormatter.
To specify a custom formatter for a property, you create a component of your class and then register the component with the /atg/search/repository/MetaPropertyValueFormatterRegistry component. MetaPropertyValueFormatterRegistry has a valueFormatterMap property which maps property names to their associated formatter components. For example, to specify that the PriceMetaPropertyValueFormatter should be applied to the price property, Oracle ATG Web Commerce adds this configuration:
valueFormatterMap+=\
price=/atg/commerce/search/PriceMetaPropertyValueFormatter
When it formats a value, RefinementValueDroplet first checks the MetaPropertyValueFormatterRegistry to see if there is a custom MetaPropertyValueFormatter registered for the property name, and if there is, uses that formatter. If there no custom formatter registered for the property, it uses the DefaultMetaPropertyValueFormatter.

