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 Tue, 30 Apr 2002 01:21:31 GMT
shawn       02/04/29 18:21:31

  Modified:    standard/src/org/apache/taglibs/standard/lang/support
                        ExpressionEvaluatorManager.java
               standard/src/org/apache/taglibs/standard/tag/common/core
                        SetSupport.java
  Log:
  Support for type coercions in <c:set>.
  
  Revision  Changes    Path
  1.6       +15 -4     jakarta-taglibs/standard/src/org/apache/taglibs/standard/lang/support/ExpressionEvaluatorManager.java
  
  Index: ExpressionEvaluatorManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/lang/support/ExpressionEvaluatorManager.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ExpressionEvaluatorManager.java	29 Apr 2002 16:31:43 -0000	1.5
  +++ ExpressionEvaluatorManager.java	30 Apr 2002 01:21:31 -0000	1.6
  @@ -59,6 +59,9 @@
   import javax.servlet.*;
   import javax.servlet.jsp.*;
   import javax.servlet.jsp.tagext.*;
  +import org.apache.taglibs.standard.lang.jstl.Coercions;
  +import org.apache.taglibs.standard.lang.jstl.Logger;
  +import org.apache.taglibs.standard.lang.jstl.ELException;
   
   /**
    * <p>A conduit to the JSTL EL.  Based on...</p>
  @@ -85,7 +88,7 @@
       // Internal, static state
   
       private static HashMap nameMap = new HashMap();
  -
  +    private static Logger logger = new Logger(System.out);
   
       //*********************************************************************
       // Public static methods
  @@ -129,9 +132,6 @@
               attributeName, expression, expectedType, null, pageContext));
       }
   
  -    //*********************************************************************
  -    // Public static utility method (un-spec'd, local to RI)
  -
       /**
        * Gets an ExpressionEvaluator from the cache, or seeds the cache
        * if we haven't seen a particular ExpressionEvaluator before.
  @@ -165,6 +165,17 @@
                   "couldn't instantiate ExpressionEvaluator: " +
                   ex.getMessage(), ex);
           }
  +    }
  +
  +    /** Performs a type conversion according to the EL's rules. */
  +    public static Object coerce(Object value, Class classe)
  +            throws JspException {
  +	try {
  +	    // just delegate the call
  +	    return Coercions.coerce(value, classe, logger);
  +	} catch (ELException ex) {
  +	    throw new JspException(ex);
  +	}
       }
   
   } 
  
  
  
  1.7       +5 -2      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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- SetSupport.java	19 Apr 2002 00:32:38 -0000	1.6
  +++ SetSupport.java	30 Apr 2002 01:21:31 -0000	1.7
  @@ -167,8 +167,11 @@
   		    boolean succeeded = false;
                       for (int i = 0; i < pd.length; i++) {
                           if (pd[i].getName().equals(property)) {
  -			    pd[i].getWriteMethod().invoke(target,
  -			        new Object[] { result });
  +			    Method m = pd[i].getWriteMethod();
  +			    m.invoke(target,
  +			             new Object[] { 
  +				       ExpressionEvaluatorManager.coerce(
  +					  result, m.getParameterTypes()[0])});
   			    succeeded = 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