You can modify the tag converters provided in the Oracle ATG Web Commerce platform; you can also create a custom tag converter in the following steps:
Extend an existing tag converter class or create one that implements interface
atg.droplet.TagConverter. The new class must implement the following TagConverter methods:Optionally, create attributes for the tag converter through an instance of the
TagAttributeDescriptorclass.Register the new tag converter with the TagConverterManager (
atg.droplet.TagConverterManager) by callingTagConverterManager.registerTagConverter()with an instance of the new tag converter’s class. The tag converter must be registered before a JSP can use it. Include the call toregisterTagConverter()in a class that is initialized during the startup process of your module—that is, is in theInitialservices list.
getName()
Returns the name of the tag converter that is supplied as an argument to the converter attribute. For example, the getName() method that is implemented by the tag converter class atg.droplet.CurrencyTagConverter returns the string currency. So, a dsp:valueof tag specifies this tag converter as follows:
<dsp:valueof param="myPrice" converter="currency"/>
getTagAttributeDescriptors()
Returns an array of TagAttributeDescriptors (atg.droplet.TagAttributeDescriptor). The constructor for a TagAttributeDescriptor is defined as follows:
TagAttributeDescriptor(String pName, String pDescription, boolean pOptional, boolean pAutomatic)
Each TagAttributeDescriptor is defined with an attribute name and description, and two Boolean properties:
Optional: Specifies whether this attribute is optional or required. For example, Oracle ATG Web Commerce’scurrencyconverter takes alocaleattribute whoseOptionalproperty is set totrue. If this attribute is omitted, the locale associated with the current request is used. Conversely, theDateconverter’sdateattribute is marked as required, so allDateconverters must supply a date format.Automatic: Not supported for custom tag converter, this property specifies whether you can supply the attribute without theconverterattribute. Only one attribute be marked as automatic; all other attributes must set this property tofalse.
For example, the tag converter class atg.droplet.Warthog defines the two attributes, recommendations and winddirection, and sets their Optional and Automatic properties as follows:
public class Warthog implements TagConverter
{
...
static final String RECS_ATTRIBUTE = "recommendations";
static final String WINDDIR_ATTRIBUTE = " winddirection";
...
private final static TagAttributeDescriptor[] sTagAttributeDescriptors = {
new TagAttributeDescriptor(RECS_ATTRIBUTE,
"A string for recommendations",
false, false),
new TagAttributeDescriptor(WINDDIR_ATTRIBUTE,
"A string for wind direction",
true, false),
}Note: Two constraints apply to custom tag converter attributes:
The
Automaticproperty is supported only for Oracle ATG Web Commerce tag converters; DSP tags can only reference custom tag converters through theconverterattribute.Custom tag converters must reference their attributes through the
converterattributesattribute. See Using Custom Tag Converters for details.
convertStringToObject()
This method is called when a tag converter is used by one of the following DSP tags:
| On form submission,
|
|
|
convertObjectToString()
This method is called in two situations:
When you use a converter in a
valueoftag, this method is used to convert theObjectvalue into aStringvalue before displaying it.When you use this tag in an
inputtag with abeanattribute and no existingvalueattribute, this method is called to fill in thevalueattribute with the current value of the bean property.

