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.
    Empty?

    It did not.

  2. I outputted the count in the output oparam to see if it was looping through the collection.
     

    It was looping through the collection.

  3. Finally I debugged using Eclipse the ForEach code.  The ForEach code can be found in /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 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.

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.


 
 
 
  
 

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.

 


Leave a Reply

Your email address will not be published. Required fields are marked *