Tag: tag converters
ATG Date Tag Converter is Buggy
by Frank Kim on Nov.23, 2009, under Page Development
(Photo: Leaf on my car by exfordy)
The ATG Date Tag Converter is buggy because Java’s DateFormat is inherently unsafe for multithreaded use. This is documented in ATG PR #123210 DateTagConverter.convertObjectToString() method is not thread safe.
You run into this problem whenever you do something like this.
<dsp:valueof param=”creationDate” converter=”date” date=”M/dd/yyyy”/>
Unfortunately there is no work around. If using the Date Tag Converter is not causing problems for you, i.e you don’t see a stack trace like below, then you can ignore this bug.
2009-04-17 00:19:08,220 ERROR [nucleusNamespace.atg.dynamo.servlet.dafpipeline.DynamoServlet] java.lang.ArrayIndexOutOfBoundsException: 502 at sun.util.calendar.BaseCalendar.getCalendarDateFromFixedDate(BaseCalendar.java:436) at java.util.GregorianCalendar.computeFields(GregorianCalendar.java:2081) at java.util.GregorianCalendar.computeFields(GregorianCalendar.java:1996) at java.util.Calendar.setTimeInMillis(Calendar.java:1071) at java.util.Calendar.setTime(Calendar.java:1037) at java.text.SimpleDateFormat.format(SimpleDateFormat.java:785) at java.text.SimpleDateFormat.format(SimpleDateFormat.java:778) at java.text.DateFormat.format(DateFormat.java:314) at atg.droplet.DateTagConverter.convertObjectToString(DateTagConverter.java:176)
But if you do see a bug like this then you might need to create a custom droplet to format the date. The droplet should only use DateFormat instances that are not static. I usually make my DateFormat instances local.
ATG Currency Converter Not Working With JSTL c:set
by Frank Kim on Aug.12, 2009, under Page Development
This JSP code was not outputting the properly formatted amount.
<dspel:valueof value="${dollars}" converter="currency" />
I tried forcing it by specifying the conversion parameters.
<dspel:valueof value="${dollars}" converter="currency" locale="en-CA" format="#.00" currency="$" />
I then debugged atg.droplet.CurrencyTagConverter using Eclipse and found this code being executed.
public String convertObjectToString(DynamoHttpServletRequest pRequest,
Object pValue, Properties pAttributes)
throws TagConversionException
{
if ((pValue == null) || (pValue instanceof String))
return (String)pValue;
It turns out pValue was a String which is why it was never being formatted. But why is it a String?
Well the code that sets dollars looks like this.
<dspel:tomap var="paymentGroup" param="commerceItem.paymentGroups[1]" />
<c:set var="dollars" value="0" />
<c:if test="${not empty paymentGroup}">
<c:set var="dollars" value="${paymentGroup.amount}" />
</c:if>
Apparently c:set converts the Double to a String.
To work around this problem I did this.
$<dspel:valueof number="0.00" value="${dollars}" />
For further reading please see Tag Converters in the ATG Page Developer’s Guide.

