1. opensymphony
  2. webwork


mbogaert  committed 3af3198

Adding an iterator to the context when you have the collection is bad practice - the issue of concern is the 'non-resettablity' of the Iterator. If a 'naked' Iterator is placed into the context, and used in more than one #foreach(), subsequent #foreach() blocks after the first will fail, as the Iterator doesn't reset.

See http://jakarta.apache.org/velocity/developer-guide.html#Support%20for%20Iterative%20Objects%20for%20#foreach()

git-svn-id: http://svn.opensymphony.com/svn/webwork/trunk@341573baa09-0c28-0410-bef9-dab3c582ae83

  • Participants
  • Parent commits 0072e90
  • Branches master

Comments (0)

Files changed (1)

File src/java/com/opensymphony/webwork/views/jsp/ui/AbstractListTag.java

View file
     public void evaluateExtraParams(OgnlValueStack stack) {
         if (listAttr != null) {
             Object value = findValue(listAttr);
-            addParam("list", MakeIterator.convert(value));
+            if (value instanceof Collection) {
+                addParam("list", value);
+            }
+            else {
+                addParam("list", MakeIterator.convert(value));
+            }
             if (value instanceof Collection) {
                 addParam("listSize", new Integer(((Collection) value).size()));