ATG Currency Converter Not Working With JSTL c:set

Currency conversion confusion on Flickr!

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.

JavaScript Invalid Argument in Internet Explorer Only

Today I noticed one of my links were not working.  This was only happening in Internet Explorer 8.  Looking down at the status bar in the lower left corner I saw the message “Error on page.”  Double-clicking on it popped up this window full of useless information.

Internet Explorer 8 invalid argument JavaScript error

A Google search for “internet explorer invalid argument” brought me to this page, Internet Explorer Sucks.  Fortunately the author had run into this problem and figured out the solution.

It turns out In Internet Explorer, the second argument to the JavaScript window.open method, which is the windowName argument, can’t have spaces. My original link looked like this.

<a href="javascript:void(0);" onclick="window.open('popUp.jsp','Frank Kim betweenGo','menubar=0,toolbar=0,location=0,scrollbars=yes,width=400,height=175')">What's this?</a>

When I took out the spaces from the windowName argument the link worked.  You would think Internet Explorer 8 would have fixed this issue by now, it doesn’t affect any other modern web browser.

How to Add Products to Categories using Content Groups

Typically after you create a category in your catalog you then add products to the category.  The simple way to do that in ATG eCommerce is to use the ACC and add products to the child products property of the category.  However there is another way.

In the ATG Commerce Guide to Setting Up a Store documentation you can see in the Viewing the Product Catalog section that a category can have child products but also child product groups.

Product Catalog

Child product groups are actually content groups which are described in the Creating Content Groups chapter of the ATG Personalization Guide for Business Users.

Targeting > Profile and Content Groups window

Though the documentation shows a content group composed of features you can easily create a content group using the ProductCatalog as a content source and product as a content type.

To create a content group follow the steps in the ATG documentation for Creating New Content Groups except use an item from the ProductCatalog when specifying the Content Type.  Then create the targeting rules for this Content Group.  Now you can specify this group in the Child products (group) property of a category.

ATG Product Bundles

what's in my sxsw schwag bag - photo by joey.parsons - Flickr

Out of the box ATG eCommerce does not support product bundles.  It does support SKU bundles, i.e. a product can consist of multiple SKU’s.

To support product bundles is pretty simple to implement.

First you create a new type of product for bundles in /atg/commerce/catalog/productCatalog.xml.

<item-descriptor name="product">
 <table name="dcs_product">
  <property name="type" data-type="enumerated" default="regular">
   <attribute name="useCodeForValue" value="false"/>
   <option value="regular" code="0"/>
   <option value="bundle" code="1" />
 </property>
 </table>


Then you define your bundles product to have the new products property. This property is simply a list of products that the bundle contains, e.g. Costco organic cotton polo shirt and Nike athletic shorts.

<item-descriptor name="bundle" super-type="product" sub-type-value="bundle">
 <table name="betweengo_product_bundle" multi-column-name="seq_num"
  type="multi" id-column-names="product_bundle_id">
  <property name="products" column-name="product_id" data-type="list"
   component-item-type="product" display-name="Products" category="Bundle" />
 </table>
</item-descriptor>

A few years ago I did a more advanced version of this implementation which allowed for different numbers of products in one bundle, e.g. two different kinds of shirts and one pair of pants.  I did this using the concept of product links which is similar to SKU links that ATG supports.

If you are interested in wanting to implement a more advanced version please contact us.

How to Debug No Output for ATG ForEach

foreach

Today I added a feature in my shopping cart JSP page but nothing was showing up.  This was because the output of ATG ForEach droplet was blanks.

To debug this I did the following steps.

  1. I added an empty oparam to see if the ForEach droplet thought the collection was empty.
    <dsp:oparam="empty">Empty?</dsp:oparam>

    It did not.

  2. I outputted the count in the output oparam to see if it was looping through the collection.
    <dsp:oparam="output"><dsp:valueof param="count"/> <dsp:valueof param="element"/></dsp:oparam>

    It was looping through the collection.

  3. Finally I debugged using Eclipse the ForEach code.  The ForEach code can be found in <ATG>/DAS/src/Java/atg/droplet/ForEach.java

    Using the debugger I realized that the element name of the loop was being set to something else which is why <dsp:valueof param=”element”/> was blank.

It turned out that the ForEach droplet was inside another ForEach droplet and in that droplet they set the element name like this.

<dsp:param name="elementName" value="CommerceItem" />

By setting the elementName parameter to something else in my ForEach droplet and then referencing it properly I was finally able to get the expected output.

<dsp:droplet name="/atg/dynamo/droplet/ForEach">
 <dsp:param name="array" param="CommerceItem.auxiliaryData.productRef.dvds"/>
 <dsp:param name="elementName" value="dvd" />
 <dsp:oparam name="output">
  <dsp:valueof param="dvd.name" />
 </dsp:oparam>
</dsp:droplet>

By the way ATG documentation suggests not using elementName.

elementName and indexName allow you to provide a parameter name other than element and index, respectively. A better way to provide a different parameter name is to use the dsp:setvalue tag.

In our example we would do this instead of setting the elementName param.

 <dsp:setvalue param="dvd" paramvalue="element" />

betweenGo now on Twitter

betweenGo is now on Twitter so you can follow us there too.

I used the following image of an Apple aluminum MacBook keyboard from William Hook on Flickr as my icon.

Apple Aluminum MacBook (Late 2008) on Flickr

http://www.flickr.com/photos/williamhook/2971294143/

I was going to use this image called “ATG on Red and Pink” from bixentro as my Twitter background but it didn’t look very good as a background.

ATG on Red and Pink on Flickr

I finally chose this one simply titled “ATG” by delete08 because it was more striking.

ATG

Debug ATG running on JBoss with Eclipse

Configuring Eclipse for Remote Debugging - O'Reilly Media 

With Eclipse debugging an ATG application running on JBoss is fairly straightforward.

  1. Configure JBoss to start up with Java options for debugging.

    On UNIX you do this by uncommenting this line in <JBoss>/bin/run.conf.

    #JAVA_OPTS="$JAVA_OPTS -Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y"

    On Windows you do this by uncommenting this line in <JBoss>/bin/run.bat.

    rem set JAVA_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y %JAVA_OPTS%
  2. Create a remote Java application debug configuration using the port you specified in step 1.  The default port is 8787.

For further reading please see Debugging Nucleus components in JBoss with Eclipse or Remote Debugging with Eclipse.  There is also a very complete tutorial from O’Reilly Media called Configuring Eclipse for Remote Debugging.

ATG ForEach Output with Separators Between Items

Pez Collection

Sometimes you want to list each item in the collection with a separator in between like a comma or slash.  However the trick is to have the separator only in between items.

In ATG DSP you can use the ForEach droplet to iterate through each item in a collection.  However to put a separator between each item is not straight-forward with this droplet.  To do this I used JSTL to test if we are at the end of the collection.  If we are then I don’t add the separator, otherwise I do.

Here is an example.

<dspel:droplet name="/atg/dynamo/droplet/ForEach">
 <dspel:param name="array" param="dvds"/>
 <dspel:setvalue param="dvd" paramvalue="element" />
 <dspel:oparam name="outputStart">
  <dspel:getvalueof var="size" param="size" />
 </dspel:oparam>
 <dspel:oparam name="output">
  <dspel:valueof param="dvd.title" valueishtml="true"/>
  <dspel:getvalueof var="count" param="count" />
  <c:if test="${size != count}"> , </c:if>
 </dspel:oparam>
</dspel:droplet>

And here is the output for this example.

The Incredibles, Ratatouille, Cars

Do you have a better or more elegant solution?  Please feel free to let me know in the comments?

How to Get Permission to Create Scenarios in ACC

This is Happening without your Permission

Sometimes you will find that you cannot create or duplicate scenarios.  You keep clicking on the grayed out New Scenario button and right-clicking on scenarios you want to duplicate but nothing happens.

Fortunately the solution is rather simple and is alluded to in the ATG Personalization Programming Guide – Configuring the Process Editor Server.

First you create a scenarioManager.xml file in your <ATG>/home/localconfig/atg/scenario directory like the following.

<?xml version="1.0" encoding="ISO-8859-1" ?>
<process-manager-configuration>

  <process-editor-server>
    <server-name>foobar:8850</server-name>
  </process-editor-server>

</process-manager-configuration>

Next you replace foobar:8850 with the value of /atg/dynamo/service/ServerName.serverName.  You may want to configure the serverName value to something you want because sometimes it might change if for example when you connect via VPN.

Then you restart ATG and reconnect or restart the ACC and you should be able to create and duplicate scenarios.

(Note that when you create the workflowProcessManager.xml file in your <ATG>/home/localconfig/atg/epub/workflow/process directory it can have the exact same contents as the scenarioManager.xml file.)

NameNotFoundExceptions during start up of ATG application on JBoss

When you start up your ATG application on JBoss and see NameNotFoundExceptions like the following it could be because you did not configure your ATG datasources correctly.

Unable to start service "/atg/dynamo/service/jdbc/JTDataSource":
 atg.nucleus.ServiceException:
 Unable to resolve reference to JNDI component:
 java:/atgcore_ds
ERROR [nucleusNamespace.atg.dynamo.service.jdbc.JTDataSource]
javax.naming.NameNotFoundException: atgcore_ds not bound

To properly configure it create an atg-oracle-ds.xml file. I have a sample one below. atgcore_ds is the datasource for most of the ATG repositories. You will probably need to configure datasources for Catalog A and Catalog B if you are doing eCommerce, e.g. atgcataloga_ds and atgcatalogb_ds. The atg-oracle-ds.xml file will go into your server’s configuration, e.g. <jboss>/server/betweengo/deploy.

<?xml version="1.0" encoding="UTF-8"?>
<datasources>
 <local-tx-datasource>
  <jndi-name>atgcore_ds</jndi-name>
  <!-- <connection-url>jdbc:oracle:oci:@Dynamo</connection-url> -->
  <connection-url>jdbc:oracle:thin:@localhost:1521:orcl</connection-url>
  <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
  <user-name>foo</user-name>
  <password>bar</password>
  <min-pool-size>1</min-pool-size>
  <max-pool-size>4</max-pool-size>
 </local-tx-datasource>
</datasources>

Note that the connection URL should be the same as what you configured in your tnsnames.ora file.  If you installed Oracle with a Microsoft Loopback Adapter and pointed the host in your tnsnames.ora configuration to the loopback connection, e.g. 192.168.1.200, then you should do the same in your atg-oracle-ds.xml file.

For further reading please see Getting Started with ATG – jBoss and Oracle and Create Additional JBoss Application Server Configurations.