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.
