jakarta-taglibs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sh...@apache.org
Subject cvs commit: jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/core ImportSupport.java
Date Fri, 08 Mar 2002 04:04:35 GMT
shawn       02/03/07 20:04:35

  Modified:    standard/src/javax/servlet/jsp/jstl/core LoopTagSupport.java
               standard/src/org/apache/taglibs/standard/tag/common/core
                        ImportSupport.java
  Log:
  Changed behavior of "nested" variables:  they are now removed, not restored,
  when the tag completes.
  
  Revision  Changes    Path
  1.4       +7 -49     jakarta-taglibs/standard/src/javax/servlet/jsp/jstl/core/LoopTagSupport.java
  
  Index: LoopTagSupport.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/src/javax/servlet/jsp/jstl/core/LoopTagSupport.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- LoopTagSupport.java	5 Mar 2002 17:08:25 -0000	1.3
  +++ LoopTagSupport.java	8 Mar 2002 04:04:35 -0000	1.4
  @@ -166,8 +166,6 @@
       private int index;                          // the current internal index
       private int count;                          // the iteration count
       private boolean last;                       // current round == last one?
  -    private Object oldItem, oldStatus;		// variables we overwrite
  -    private int oldItemScope, oldStatusScope;	// scopes of these variables
   
       //*********************************************************************
       // Constructor
  @@ -255,35 +253,6 @@
           count = 1;
           last = false;
   
  -	// save old 'items' and 'status' if applicable
  -	/* (Note that we are somewhat anal-retentive and record the
  -         * scope of the variable we overwrite.  If the container attribute
  -         * truly implements scoped attributes as a single namespace,
  -	 * this may become important.  Ultimately, either findAttribute()
  -	 * will stop at 'page' and this won't make a different, or it
  -	 * will stop at something OTHER than 'page'.  If we find a variable
  -         * outside page scope, we know that there was no variable of the
  -         * same name WITHIN page scope, because of findAttribute()'s
  -         * semantics.  Therefore, if we save this attribute, we know we're
  -         * not missing anything in 'page'.  Thus, we are prepared for a
  -         * container that overwrites a 'session'-scoped attribute on a
  -         * call to setAttribute() to establish a 'page'-scoped attribute -- 
  -         * which I believe is a legal implementation of setAttribute().
  -         * If a user sets a session-scoped variable of the same name as
  -         * itemId or statusId within her <c:forEach> loop, however, this
  -         * could lead to some pretty unusual behavior.  I have opted to
  -         * stick with section JSP2.8.2 of the JSP spec instead of to
  -         * assume a page author will ignore this section.)
  -         */
  -	if (itemId != null) {
  -	    oldItem = pageContext.findAttribute(itemId);
  -	    oldItemScope = pageContext.getAttributesScope(itemId);
  -	}
  -	if (statusId != null) {
  -	    oldStatus = pageContext.findAttribute(statusId);
  -	    oldStatusScope = pageContext.getAttributesScope(statusId);
  -	}
  -
           // let the subclass conduct any necessary preparation
           prepare();
   
  @@ -523,10 +492,6 @@
           beginSpecified = false; // not specified until it's specified :-)
           endSpecified = false;   // (as above)
           stepSpecified = false;  // (as above)
  -	oldItem = null;		// no page-variable saved
  -	oldStatus = null;	// no page-variable saved
  -	oldItemScope = 0;	// no page-variable saved
  -	oldStatusScope = 0;	// no page-variable saved
   
           // defaults for interface with page author
           begin = 0;              // when not specified, 'begin' is 0 by spec.
  @@ -572,13 +537,13 @@
   
           if (itemId != null) {
               if (getCurrent() == null)
  -                pageContext.removeAttribute(itemId);
  +                pageContext.removeAttribute(itemId, PageContext.PAGE_SCOPE);
               else
                   pageContext.setAttribute(itemId, getCurrent());
           }
           if (statusId != null) {
               if (getIteratorStatus() == null)
  -                pageContext.removeAttribute(statusId);
  +                pageContext.removeAttribute(statusId, PageContext.PAGE_SCOPE);
               else
                   pageContext.setAttribute(statusId, getIteratorStatus());
           }
  @@ -590,18 +555,11 @@
        * restores them to their prior values (and scopes).
        */
       private void unExposeVariables() {
  -	if (itemId != null) {
  -	    if (oldItem == null)
  -	        pageContext.removeAttribute(itemId, PageContext.PAGE_SCOPE);
  -	    else
  -		pageContext.setAttribute(itemId, oldItem, oldItemScope);
  -	}
  -	if (statusId != null) {
  -	    if (oldStatus == null)
  -		pageContext.removeAttribute(statusId, PageContext.PAGE_SCOPE);
  -	    else
  -		pageContext.setAttribute(statusId, oldStatus, oldStatusScope);
  -	}
  +        // "nested" variables are now simply removed
  +	if (itemId != null)
  +            pageContext.removeAttribute(itemId, PageContext.PAGE_SCOPE);
  +	if (statusId != null)
  +	    pageContext.removeAttribute(statusId, PageContext.PAGE_SCOPE);
       }
   
       /**
  
  
  
  1.6       +1 -7      jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/core/ImportSupport.java
  
  Index: ImportSupport.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/core/ImportSupport.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ImportSupport.java	4 Feb 2002 03:39:39 -0000	1.5
  +++ ImportSupport.java	8 Mar 2002 04:04:35 -0000	1.6
  @@ -111,7 +111,6 @@
       private int scope;			// processed 'scope' attribute
       private String varReader;           // 'varReader' attribute
       private Reader r;	 		// exposed reader, if relevant
  -    private Object oldVarReader;	// overwritten attribute
       private boolean isAbsoluteUrl;	// is our URL absolute?
       private String urlWithParams;	// URL with <param>-added text
   
  @@ -148,8 +147,6 @@
   	    // If we need to expose a Reader, we've got to do it right away
   	    if  (varReader != null) {
   	        r = acquireReader();
  -	        Object oldVarReader =
  -		    pageContext.getAttribute(varReader);
   	        pageContext.setAttribute(varReader, r);
   	    }
   	} catch (IOException ex) {
  @@ -194,10 +191,7 @@
   		// 'r' can be null if an exception was thrown...
   	        if (r != null)
   		    r.close();
  -	        if (oldVarReader != null)
  -		    pageContext.setAttribute(varReader, oldVarReader);
  -		else
  -		    pageContext.removeAttribute(varReader);
  +		pageContext.removeAttribute(varReader, PageContext.PAGE_SCOPE);
   	    }
           } catch (IOException ex) {
   	    // ignore it; close() failed, but there's nothing more we can do
  
  
  

--
To unsubscribe, e-mail:   <mailto:taglibs-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:taglibs-dev-help@jakarta.apache.org>


Mime
View raw message