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 SetSupport.java
Date Thu, 18 Apr 2002 23:08:40 GMT
shawn       02/04/18 16:08:40

  Modified:    standard/src/org/apache/taglibs/standard/lang/jstl
                        Evaluator.java
               standard/src/org/apache/taglibs/standard/resources
                        Resources.properties
               standard/src/org/apache/taglibs/standard/tag/common/core
                        SetSupport.java
  Log:
  Fixed several minor bugs.
  
  Revision  Changes    Path
  1.5       +179 -179  jakarta-taglibs/standard/src/org/apache/taglibs/standard/lang/jstl/Evaluator.java
  
  Index: Evaluator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/lang/jstl/Evaluator.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Evaluator.java	14 Apr 2002 14:32:35 -0000	1.4
  +++ Evaluator.java	18 Apr 2002 23:08:39 -0000	1.5
  @@ -1,179 +1,179 @@
  -/*
  - * The Apache Software License, Version 1.1
  - *
  - * Copyright (c) 1999 The Apache Software Foundation.  All rights 
  - * reserved.
  - *
  - * Redistribution and use in source and binary forms, with or without
  - * modification, are permitted provided that the following conditions
  - * are met:
  - *
  - * 1. Redistributions of source code must retain the above copyright
  - *    notice, this list of conditions and the following disclaimer. 
  - *
  - * 2. Redistributions in binary form must reproduce the above copyright
  - *    notice, this list of conditions and the following disclaimer in
  - *    the documentation and/or other materials provided with the
  - *    distribution.
  - *
  - * 3. The end-user documentation included with the redistribution, if
  - *    any, must include the following acknowlegement:  
  - *       "This product includes software developed by the 
  - *        Apache Software Foundation (http://www.apache.org/)."
  - *    Alternately, this acknowlegement may appear in the software itself,
  - *    if and wherever such third-party acknowlegements normally appear.
  - *
  - * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
  - *    Foundation" must not be used to endorse or promote products derived
  - *    from this software without prior written permission. For written 
  - *    permission, please contact apache@apache.org.
  - *
  - * 5. Products derived from this software may not be called "Apache"
  - *    nor may "Apache" appear in their names without prior written
  - *    permission of the Apache Group.
  - *
  - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  - * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  - * SUCH DAMAGE.
  - * ====================================================================
  - *
  - * This software consists of voluntary contributions made by many
  - * individuals on behalf of the Apache Software Foundation.  For more
  - * information on the Apache Software Foundation, please see
  - * <http://www.apache.org/>.
  - *
  - */ 
  -
  -package org.apache.taglibs.standard.lang.jstl;
  -
  -import java.text.MessageFormat;
  -import javax.servlet.jsp.JspException;
  -import javax.servlet.jsp.PageContext;
  -import javax.servlet.jsp.tagext.Tag;
  -import org.apache.taglibs.standard.lang.support.ExpressionEvaluator;
  -
  -/**
  - *
  - * <p>This is the expression evaluator "adapter" that customizes it
  - * for use with the JSP Standard Tag Library.  It uses a
  - * VariableResolver implementation that looks up variables from the
  - * PageContext and also implements its implicit objects.  It also
  - * wraps ELExceptions in JspExceptions that describe the attribute
  - * name and value causing the error.
  - * 
  - * @author Nathan Abramson - Art Technology Group
  - * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: arista $
  - **/
  -
  -public class Evaluator
  -  implements ExpressionEvaluator
  -{
  -  //-------------------------------------
  -  // Properties
  -  //-------------------------------------
  -
  -  //-------------------------------------
  -  // Member variables
  -  //-------------------------------------
  -
  -  /** The singleton instance of the evaluator **/
  -  static ELEvaluator sEvaluator =
  -    new ELEvaluator
  -    (new JSTLVariableResolver ());
  -
  -  //-------------------------------------
  -  // ExpressionEvaluator methods
  -  //-------------------------------------
  -  /** 
  -   *
  -   * Translation time validation of an attribute value.  This method
  -   * will return a null String if the attribute value is valid;
  -   * otherwise an error message.
  -   **/ 
  -  public String validate (String pAttributeName,
  -			  String pAttributeValue)
  -  {
  -    try {
  -      sEvaluator.parseExpressionString (pAttributeValue);
  -      return null;
  -    }
  -    catch (ELException exc) {
  -      return
  -	MessageFormat.format
  -	(Constants.ATTRIBUTE_PARSE_EXCEPTION,
  -	 new Object [] {
  -	   "" + pAttributeName,
  -	   "" + pAttributeValue,
  -	   exc.getMessage ()
  -	 });
  -    }
  -  }
  -
  -  //-------------------------------------
  -  /**
  -   *
  -   * Evaluates the expression at request time
  -   **/
  -  public Object evaluate (String pAttributeName,
  -			  String pAttributeValue,
  -			  Class pExpectedType,
  -			  Tag pTag,
  -			  PageContext pPageContext)
  -    throws JspException
  -  {
  -    try {
  -      return sEvaluator.evaluate
  -	(pAttributeValue,
  -	 pPageContext,
  -	 pExpectedType);
  -    }
  -    catch (ELException exc) {
  -      return new JspException
  -	(MessageFormat.format
  -	 (Constants.ATTRIBUTE_EVALUATION_EXCEPTION,
  -	  new Object [] {
  -	    "" + pAttributeName,
  -	    "" + pAttributeValue,
  -	    exc.getMessage ()
  -	  }));
  -    }
  -  }
  -
  -  //-------------------------------------
  -  // Testing methods
  -  //-------------------------------------
  -  /**
  -   *
  -   * Parses the given attribute value, then converts it back to a
  -   * String in its canonical form.
  -   **/
  -  public static String parseAndRender (String pAttributeValue)
  -    throws JspException
  -  {
  -    try {
  -      return sEvaluator.parseAndRender (pAttributeValue);
  -    }
  -    catch (ELException exc) {
  -      throw new JspException
  -	(MessageFormat.format
  -	 (Constants.ATTRIBUTE_PARSE_EXCEPTION,
  -	  new Object [] {
  -	    "test",
  -	    "" + pAttributeValue,
  -	    exc.getMessage ()
  -	  }));
  -    }
  -  }
  -
  -  //-------------------------------------
  -
  -}
  +/*
  + * The Apache Software License, Version 1.1
  + *
  + * Copyright (c) 1999 The Apache Software Foundation.  All rights 
  + * reserved.
  + *
  + * Redistribution and use in source and binary forms, with or without
  + * modification, are permitted provided that the following conditions
  + * are met:
  + *
  + * 1. Redistributions of source code must retain the above copyright
  + *    notice, this list of conditions and the following disclaimer. 
  + *
  + * 2. Redistributions in binary form must reproduce the above copyright
  + *    notice, this list of conditions and the following disclaimer in
  + *    the documentation and/or other materials provided with the
  + *    distribution.
  + *
  + * 3. The end-user documentation included with the redistribution, if
  + *    any, must include the following acknowlegement:  
  + *       "This product includes software developed by the 
  + *        Apache Software Foundation (http://www.apache.org/)."
  + *    Alternately, this acknowlegement may appear in the software itself,
  + *    if and wherever such third-party acknowlegements normally appear.
  + *
  + * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
  + *    Foundation" must not be used to endorse or promote products derived
  + *    from this software without prior written permission. For written 
  + *    permission, please contact apache@apache.org.
  + *
  + * 5. Products derived from this software may not be called "Apache"
  + *    nor may "Apache" appear in their names without prior written
  + *    permission of the Apache Group.
  + *
  + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  + * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  + * SUCH DAMAGE.
  + * ====================================================================
  + *
  + * This software consists of voluntary contributions made by many
  + * individuals on behalf of the Apache Software Foundation.  For more
  + * information on the Apache Software Foundation, please see
  + * <http://www.apache.org/>.
  + *
  + */ 
  +
  +package org.apache.taglibs.standard.lang.jstl;
  +
  +import java.text.MessageFormat;
  +import javax.servlet.jsp.JspException;
  +import javax.servlet.jsp.PageContext;
  +import javax.servlet.jsp.tagext.Tag;
  +import org.apache.taglibs.standard.lang.support.ExpressionEvaluator;
  +
  +/**
  + *
  + * <p>This is the expression evaluator "adapter" that customizes it
  + * for use with the JSP Standard Tag Library.  It uses a
  + * VariableResolver implementation that looks up variables from the
  + * PageContext and also implements its implicit objects.  It also
  + * wraps ELExceptions in JspExceptions that describe the attribute
  + * name and value causing the error.
  + * 
  + * @author Nathan Abramson - Art Technology Group
  + * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: shawn $
  + **/
  +
  +public class Evaluator
  +  implements ExpressionEvaluator
  +{
  +  //-------------------------------------
  +  // Properties
  +  //-------------------------------------
  +
  +  //-------------------------------------
  +  // Member variables
  +  //-------------------------------------
  +
  +  /** The singleton instance of the evaluator **/
  +  static ELEvaluator sEvaluator =
  +    new ELEvaluator
  +    (new JSTLVariableResolver ());
  +
  +  //-------------------------------------
  +  // ExpressionEvaluator methods
  +  //-------------------------------------
  +  /** 
  +   *
  +   * Translation time validation of an attribute value.  This method
  +   * will return a null String if the attribute value is valid;
  +   * otherwise an error message.
  +   **/ 
  +  public String validate (String pAttributeName,
  +			  String pAttributeValue)
  +  {
  +    try {
  +      sEvaluator.parseExpressionString (pAttributeValue);
  +      return null;
  +    }
  +    catch (ELException exc) {
  +      return
  +	MessageFormat.format
  +	(Constants.ATTRIBUTE_PARSE_EXCEPTION,
  +	 new Object [] {
  +	   "" + pAttributeName,
  +	   "" + pAttributeValue,
  +	   exc.getMessage ()
  +	 });
  +    }
  +  }
  +
  +  //-------------------------------------
  +  /**
  +   *
  +   * Evaluates the expression at request time
  +   **/
  +  public Object evaluate (String pAttributeName,
  +			  String pAttributeValue,
  +			  Class pExpectedType,
  +			  Tag pTag,
  +			  PageContext pPageContext)
  +    throws JspException
  +  {
  +    try {
  +      return sEvaluator.evaluate
  +	(pAttributeValue,
  +	 pPageContext,
  +	 pExpectedType);
  +    }
  +    catch (ELException exc) {
  +      throw new JspException
  +	(MessageFormat.format
  +	 (Constants.ATTRIBUTE_EVALUATION_EXCEPTION,
  +	  new Object [] {
  +	    "" + pAttributeName,
  +	    "" + pAttributeValue,
  +	    exc.getMessage ()
  +	  }));
  +    }
  +  }
  +
  +  //-------------------------------------
  +  // Testing methods
  +  //-------------------------------------
  +  /**
  +   *
  +   * Parses the given attribute value, then converts it back to a
  +   * String in its canonical form.
  +   **/
  +  public static String parseAndRender (String pAttributeValue)
  +    throws JspException
  +  {
  +    try {
  +      return sEvaluator.parseAndRender (pAttributeValue);
  +    }
  +    catch (ELException exc) {
  +      throw new JspException
  +	(MessageFormat.format
  +	 (Constants.ATTRIBUTE_PARSE_EXCEPTION,
  +	  new Object [] {
  +	    "test",
  +	    "" + pAttributeValue,
  +	    exc.getMessage ()
  +	  }));
  +    }
  +  }
  +
  +  //-------------------------------------
  +
  +}
  
  
  
  1.27      +3 -0      jakarta-taglibs/standard/src/org/apache/taglibs/standard/resources/Resources.properties
  
  Index: Resources.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/resources/Resources.properties,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- Resources.properties	18 Apr 2002 02:17:37 -0000	1.26
  +++ Resources.properties	18 Apr 2002 23:08:40 -0000	1.27
  @@ -74,6 +74,9 @@
   SET_INVALID_PROPERTY=\
       Invalid property in &lt;set&gt;:  "{0}"
   
  +SET_INVALID_TARGET=\
  +    Attempt to set the property of an invalid object in &lt;set&gt;.
  +
   SET_NO_VALUE=\
       Need either non-whitespace body or "value" attribute in &lt;set&gt;
   
  
  
  
  1.5       +10 -6     jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/core/SetSupport.java
  
  Index: SetSupport.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/core/SetSupport.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- SetSupport.java	18 Apr 2002 16:04:03 -0000	1.4
  +++ SetSupport.java	18 Apr 2002 23:08:40 -0000	1.5
  @@ -80,6 +80,7 @@
       protected String property;                          // tag attribute
       private String var;					// tag attribute
       private int scope;					// tag attribute
  +    private boolean scopeSpecified;			// status
   
       //*********************************************************************
       // Construction and initialization
  @@ -97,7 +98,7 @@
       // resets local state
       private void init() {
           value = var = null;
  -	valueSpecified = false;
  +	scopeSpecified = valueSpecified = false;
   	scope = PageContext.PAGE_SCOPE;
       }
   
  @@ -139,9 +140,12 @@
                * is made to store something in the session without any
   	     * HttpSession existing).
                */
  -	    if (result != null)
  -	        pageContext.setAttribute(var, result, scope);
  -	    else
  +	    if (result != null) {
  +		if (scopeSpecified)
  +	            pageContext.setAttribute(var, result, scope);
  +		else
  +		    pageContext.removeAttribute(var);
  +	    } else
   		pageContext.removeAttribute(var);
   
   	} else if (target != null) {
  @@ -180,9 +184,8 @@
   		    throw new JspException(ex);
   		}
   	    }
  -
   	} else {
  -	    // should't ever occur because of validation in TLV and settesr
  +	    // should't ever occur because of validation in TLV and setters
   	    throw new JspTagException();
   	}
   
  @@ -201,5 +204,6 @@
       // for tag attribute
       public void setScope(String scope) {
           this.scope = Util.getScope(scope);
  +	this.scopeSpecified = true;
       }
   }
  
  
  

--
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