tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jboy...@apache.org
Subject svn commit: r1444585 - in /tomcat/taglibs/standard/trunk: impl/src/main/java/org/apache/taglibs/standard/tag/common/core/ForTokensSupport.java spec/src/main/java/javax/servlet/jsp/jstl/core/LoopTagSupport.java
Date Sun, 10 Feb 2013 19:10:58 GMT
Author: jboynes
Date: Sun Feb 10 19:10:57 2013
New Revision: 1444585

URL: http://svn.apache.org/r1444585
Log:
fix for #54544 where loop variables are not reset when the tag is recycled

Modified:
    tomcat/taglibs/standard/trunk/impl/src/main/java/org/apache/taglibs/standard/tag/common/core/ForTokensSupport.java
    tomcat/taglibs/standard/trunk/spec/src/main/java/javax/servlet/jsp/jstl/core/LoopTagSupport.java

Modified: tomcat/taglibs/standard/trunk/impl/src/main/java/org/apache/taglibs/standard/tag/common/core/ForTokensSupport.java
URL: http://svn.apache.org/viewvc/tomcat/taglibs/standard/trunk/impl/src/main/java/org/apache/taglibs/standard/tag/common/core/ForTokensSupport.java?rev=1444585&r1=1444584&r2=1444585&view=diff
==============================================================================
--- tomcat/taglibs/standard/trunk/impl/src/main/java/org/apache/taglibs/standard/tag/common/core/ForTokensSupport.java
(original)
+++ tomcat/taglibs/standard/trunk/impl/src/main/java/org/apache/taglibs/standard/tag/common/core/ForTokensSupport.java
Sun Feb 10 19:10:57 2013
@@ -19,7 +19,6 @@ package org.apache.taglibs.standard.tag.
 
 import java.util.StringTokenizer;
 
-import javax.el.ELContext;
 import javax.el.ValueExpression;
 import javax.servlet.jsp.JspTagException;
 import javax.servlet.jsp.jstl.core.IteratedExpression;
@@ -57,7 +56,7 @@ public abstract class ForTokensSupport e
     protected Object items;                       // 'items' attribute
     protected String delims;                      // 'delims' attribute
     protected StringTokenizer st;                 // digested tokenizer
-    protected int currentIndex = 0;
+    protected int currentIndex;
     private IteratedExpression itemsValueIteratedExpression;
 
 
@@ -73,8 +72,10 @@ public abstract class ForTokensSupport e
     protected void prepare() throws JspTagException {
         if (items instanceof ValueExpression) {
             deferredExpression = (ValueExpression) items;
-            ELContext myELContext = pageContext.getELContext();
-            Object originalValue = deferredExpression.getValue(myELContext);
+            itemsValueIteratedExpression = new IteratedExpression(deferredExpression, getDelims());
+            currentIndex = 0;
+
+            Object originalValue = deferredExpression.getValue(pageContext.getELContext());
             if (originalValue instanceof String) {
                 st = new StringTokenizer((String) originalValue, delims);
             } else {
@@ -94,12 +95,7 @@ public abstract class ForTokensSupport e
     protected Object next() throws JspTagException {
         if (deferredExpression != null) {
             st.nextElement();
-            if (itemsValueIteratedExpression == null) {
-                itemsValueIteratedExpression = new IteratedExpression(deferredExpression,
getDelims());
-            }
-            ValueExpression nextValue = new IteratedValueExpression(itemsValueIteratedExpression,
currentIndex);
-            currentIndex++;
-            return nextValue;
+            return new IteratedValueExpression(itemsValueIteratedExpression, currentIndex++);
         } else {
             return st.nextElement();
         }

Modified: tomcat/taglibs/standard/trunk/spec/src/main/java/javax/servlet/jsp/jstl/core/LoopTagSupport.java
URL: http://svn.apache.org/viewvc/tomcat/taglibs/standard/trunk/spec/src/main/java/javax/servlet/jsp/jstl/core/LoopTagSupport.java?rev=1444585&r1=1444584&r2=1444585&view=diff
==============================================================================
--- tomcat/taglibs/standard/trunk/spec/src/main/java/javax/servlet/jsp/jstl/core/LoopTagSupport.java
(original)
+++ tomcat/taglibs/standard/trunk/spec/src/main/java/javax/servlet/jsp/jstl/core/LoopTagSupport.java
Sun Feb 10 19:10:57 2013
@@ -115,7 +115,7 @@ public abstract class LoopTagSupport
      */
     protected String itemId, statusId;
 
-    protected ValueExpression deferredExpression = null;
+    protected ValueExpression deferredExpression;
 
     //*********************************************************************
     // 'Private' state (implementation details)
@@ -509,6 +509,7 @@ public abstract class LoopTagSupport
         beginSpecified = false; // not specified until it's specified :-)
         endSpecified = false;   // (as above)
         stepSpecified = false;  // (as above)
+        deferredExpression = null;
 
         // defaults for interface with page author
         begin = 0;              // when not specified, 'begin' is 0 by spec.



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message