jvanzyl 00/10/15 13:28:06
Modified: src/java/org/apache/velocity/runtime/directive Foreach.java
Log:
- grab the counter.name property so that the user defined value
can be used.
Revision Changes Path
1.8 +8 -5
jakarta-velocity/src/java/org/apache/velocity/runtime/directive/Foreach.java
Index: Foreach.java
===================================================================
RCS file:
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/directive/Foreach.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- Foreach.java 2000/10/15 20:08:06 1.7
+++ Foreach.java 2000/10/15 20:28:05 1.8
@@ -84,9 +84,12 @@
private final static int ARRAY = 1;
private final static int ITERATOR = 2;
- private final static String COUNTER_IDENTIFIER = "velocityCount";
- private final static int INITIAL_COUNTER_VALUE =
- new Integer(Runtime.getString(Runtime.INITIAL_COUNTER_VALUE)).intValue();
+
+ private final static String COUNTER_IDENTIFIER =
+ Runtime.getString(Runtime.COUNTER_NAME);
+
+ private final static int COUNTER_INITIAL_VALUE =
+ new Integer(Runtime.getString(Runtime.COUNTER_INITIAL_VALUE)).intValue();
private String elementKey;
private Object listObject;
@@ -147,7 +150,7 @@
for (int i = 0; i < length; i++)
{
context.put(COUNTER_IDENTIFIER,
- new Integer(i + INITIAL_COUNTER_VALUE));
+ new Integer(i + COUNTER_INITIAL_VALUE));
context.put(elementKey,((Object[])listObject)[i]);
node.jjtGetChild(3).render(context, writer);
}
@@ -161,7 +164,7 @@
// be faster then using an Iterator.
Iterator i = ((Collection) listObject).iterator();
- iterator = INITIAL_COUNTER_VALUE;
+ iterator = COUNTER_INITIAL_VALUE;
while (i.hasNext())
{
context.put(COUNTER_IDENTIFIER, new Integer(iterator));