cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gkossakow...@apache.org
Subject svn commit: r557252 - /cocoon/whiteboard/objectmodel/cocoon-template/cocoon-template-impl/src/main/java/org/apache/cocoon/template/instruction/ForEach.java
Date Wed, 18 Jul 2007 13:11:35 GMT
Author: gkossakowski
Date: Wed Jul 18 06:11:34 2007
New Revision: 557252

URL: http://svn.apache.org/viewvc?view=rev&rev=557252
Log:
COCOON-2092: Use ObjectModel instead of ExpressionContext in ForEach tag.

Modified:
    cocoon/whiteboard/objectmodel/cocoon-template/cocoon-template-impl/src/main/java/org/apache/cocoon/template/instruction/ForEach.java

Modified: cocoon/whiteboard/objectmodel/cocoon-template/cocoon-template-impl/src/main/java/org/apache/cocoon/template/instruction/ForEach.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/objectmodel/cocoon-template/cocoon-template-impl/src/main/java/org/apache/cocoon/template/instruction/ForEach.java?view=diff&rev=557252&r1=557251&r2=557252
==============================================================================
--- cocoon/whiteboard/objectmodel/cocoon-template/cocoon-template-impl/src/main/java/org/apache/cocoon/template/instruction/ForEach.java
(original)
+++ cocoon/whiteboard/objectmodel/cocoon-template/cocoon-template-impl/src/main/java/org/apache/cocoon/template/instruction/ForEach.java
Wed Jul 18 06:11:34 2007
@@ -20,6 +20,7 @@
 import java.util.Stack;
 
 import org.apache.cocoon.components.expression.ExpressionContext;
+import org.apache.cocoon.objectmodel.ObjectModel;
 import org.apache.cocoon.template.environment.ErrorHolder;
 import org.apache.cocoon.template.environment.ExecutionContext;
 import org.apache.cocoon.template.environment.ParsingContext;
@@ -110,8 +111,6 @@
             throw new SAXParseException(err.getMessage(),
                                         getLocation(), new ErrorHolder(err));
         }
-        ExpressionContext localExpressionContext =
-            new ExpressionContext(expressionContext);
         int i = 0;
         // Move to the begin row
         while (i < begin && iter.hasNext()) {
@@ -125,14 +124,14 @@
             status.setEnd(end);
             status.setStep(step);
             status.setFirst(true);
-            localExpressionContext.put(varStatus, status);
+            expressionContext.getObjectModel().put(varStatus, status);
         }
         int skipCounter, count = 1;
         while (i <= end && iter.hasNext()) {
             Object value = iter.next();
-            localExpressionContext.setContextBean(value);
+            expressionContext.getObjectModel().put(ObjectModel.CONTEXTBEAN, value);
             if (var != null) {
-                localExpressionContext.put(var, value);
+                expressionContext.getObjectModel().put(var, value);
             }
             if (status != null) {
                 status.setIndex(i);
@@ -141,7 +140,7 @@
                 status.setCurrent(value);
                 status.setLast((i == end || !iter.hasNext()));
             }
-            Invoker.execute(consumer, localExpressionContext, executionContext,
+            Invoker.execute(consumer, expressionContext, executionContext,
                             macroContext, getNext(), getEndInstruction());
             // Skip rows
             skipCounter = step;
@@ -151,7 +150,13 @@
             // Increase index
             i += step;
             count++;
+            
+            expressionContext.getObjectModel().remove(ObjectModel.CONTEXTBEAN, value);
+            expressionContext.getObjectModel().remove(var, value);
         }
+        if (status != null)
+            expressionContext.getObjectModel().remove(varStatus, status);
+            
         return getEndInstruction().getNext();
     }
 }



Mime
View raw message