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.
- I added an empty oparam to see if the ForEach droplet thought the collection was empty.
It did not.
- I outputted the count in the output oparam to see if it was looping through the collection.
It was looping through the collection.
- Finally I debugged using Eclipse the ForEach code. The ForEach code can be found in
Using the debugger I realized that the element name of the loop was being set to something else which is why
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.
indexNameallow you to provide a parameter name other than
index, respectively. A better way to provide a different parameter name is to use the
In our example we would do this instead of setting the elementName param.