jakarta-taglibs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hor...@apache.org
Subject cvs commit: jakarta-taglibs/standard/conf sql-rt.tld sql.tld
Date Sun, 14 Apr 2002 02:10:31 GMT
horwat      02/04/13 19:10:31

  Modified:    standard/src/org/apache/taglibs/standard/tag/common/sql
                        ParamTagSupport.java
               standard/src/org/apache/taglibs/standard/resources
                        Resources.properties
               standard/src/org/apache/taglibs/standard/tlv JstlSqlTLV.java
               standard/conf sql-rt.tld sql.tld
  Added:       standard/src/org/apache/taglibs/standard/tag/common/sql
                        DateParamTagSupport.java
               standard/src/org/apache/taglibs/standard/tag/rt/sql
                        DateParamTag.java
               standard/src/org/apache/taglibs/standard/tag/el/sql
                        DateParamTag.java
  Log:
  Added dateParam action to set SQL statement date values.
  
  Revision  Changes    Path
  1.3       +2 -5      jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/sql/ParamTagSupport.java
  
  Index: ParamTagSupport.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/sql/ParamTagSupport.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ParamTagSupport.java	4 Jan 2002 21:59:01 -0000	1.2
  +++ ParamTagSupport.java	14 Apr 2002 02:10:31 -0000	1.3
  @@ -79,7 +79,7 @@
   	    findAncestorWithClass(this, SQLExecutionTag.class);
   	if (parent == null) {
   	    throw new JspTagException(
  -                Resources.getMessage("PARAM_SQLVALUE_CONTEXT"));
  +                Resources.getMessage("SQL_PARAM_OUTSIDE_PARENT"));
   	}
   
   	Object paramValue = null;
  @@ -92,10 +92,7 @@
   		paramValue = null;
   	    }
   	}
  -	if (paramValue == null) {
  -	    throw new JspTagException(
  -               Resources.getMessage("PARAM_NO_VALUE"));
  -	}
  +
   	parent.addSQLParameter(paramValue);
   	return EVAL_PAGE;
       }
  
  
  
  1.1                  jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/sql/DateParamTagSupport.java
  
  Index: DateParamTagSupport.java
  ===================================================================
  /*
   * 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.tag.common.sql;
  
  import java.util.*;
  import java.sql.Time;
  import java.sql.Date;
  import java.sql.Timestamp;
  import javax.servlet.jsp.*;
  import javax.servlet.jsp.jstl.sql.*;
  import javax.servlet.jsp.tagext.*;
  import org.apache.taglibs.standard.resources.Resources;
  
  
  /**
   * <p>Tag handler for &lt;Param&gt; in JSTL, used to set
   * parameter values for a SQL statement.</p>
   * 
   * @author Justyna Horwat
   */
  
  public abstract class DateParamTagSupport extends BodyTagSupport {
      protected java.util.Date value;
      protected String type;
      protected Object rawValue;
  
      //*********************************************************************
      // Constructor
  
      public DateParamTagSupport() {
          super();
          init();
      }
  
      private void init() {
          value = null;
          type = "TIMESTAMP";
      }
  
      //*********************************************************************
      // Tag logic
  
      public int doEndTag() throws JspException {
  	SQLExecutionTag parent = (SQLExecutionTag) 
  	    findAncestorWithClass(this, SQLExecutionTag.class);
  	if (parent == null) {
  	    throw new JspTagException(
                  Resources.getMessage("SQL_PARAM_OUTSIDE_PARENT"));
  	}
  
          if (rawValue != null) {
              value = getConvertedValue();
          }
  
  	parent.addSQLParameter(value);
  	return EVAL_PAGE;
      }
  
      //*********************************************************************
      // Private utility methods
  
      private java.util.Date getConvertedValue() {
          if (type.equalsIgnoreCase("TIMESTAMP")) {
              if (!(rawValue instanceof java.sql.Timestamp)) {
                  return new java.sql.Timestamp(
                      ((java.util.Date)rawValue).getTime());
              }
          }
          if (type.equalsIgnoreCase("TIME")) {
              if (!(rawValue instanceof java.sql.Time)) {
                  return new java.sql.Time(
                      ((java.util.Date)rawValue).getTime());
              }
          }
          if (type.equalsIgnoreCase("DATE")) {
              if (!(rawValue instanceof java.sql.Date)) {
                  return new java.sql.Date(
                      ((java.util.Date)rawValue).getTime());
              }
          }
          return (java.util.Date)rawValue;
      }
  }
  
  
  
  1.1                  jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/rt/sql/DateParamTag.java
  
  Index: DateParamTag.java
  ===================================================================
  /*
   * 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.tag.rt.sql;
  
  import javax.servlet.jsp.*;
  import java.util.Date;
  import org.apache.taglibs.standard.lang.support.*;
  import org.apache.taglibs.standard.tag.common.sql.DateParamTagSupport;
  
  /**
   * Subclass for the JSTL library with rtexprvalue support.
   *
   * @author Justyna Horwat
   */
  public class DateParamTag extends DateParamTagSupport {
      
      public void setValue(Date value) {
  	this.rawValue = value;
      }
  
      public void setType(String type) {
  	this.type = type;
      }
  }
  
  
  
  1.1                  jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/el/sql/DateParamTag.java
  
  Index: DateParamTag.java
  ===================================================================
  /*
   * 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.tag.el.sql;
  
  import javax.servlet.jsp.*;
  import org.apache.taglibs.standard.lang.support.*;
  import org.apache.taglibs.standard.tag.common.sql.DateParamTagSupport;
  
  /**
   * Subclass for the JSTL library with EL support.
   *
   * @author Justyna Horwat
   */
  public class DateParamTag extends DateParamTagSupport {
      
      private String valueEL;
      private String typeEL;
  
      public void setValue(String valueEL) {
  	this.valueEL = valueEL;
      }
  
      public void setType(String typeEL) {
  	this.typeEL = typeEL;
      }
  
      public int doStartTag() throws JspException {
          evaluateExpressions();
  	return super.doStartTag();
      }
  
      //*********************************************************************
      // Private utility methods
  
      // Evaluates expressions as necessary
      private void evaluateExpressions() throws JspException {
  	if (valueEL != null) {
  	    rawValue = (Object) 
  		ExpressionEvaluatorManager.evaluate("value", valueEL, 
  		    Object.class, this, pageContext);
  	}
  	if (typeEL != null) {
  	    type = (String) 
  		ExpressionEvaluatorManager.evaluate("type", typeEL, 
  		    String.class, this, pageContext);
          }
      }
  
  }
  
  
  
  1.18      +1 -4      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.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- Resources.properties	11 Apr 2002 01:00:08 -0000	1.17
  +++ Resources.properties	14 Apr 2002 02:10:31 -0000	1.18
  @@ -151,9 +151,6 @@
   DRIVER_INVALID_CLASS=\
       In &lt;driver&gt;, invalid driver class name: "{0}"
   
  -PARAM_SQLVALUE_CONTEXT=\
  -    In &lt;param&gt;, "sqlValue" used in wrong context
  -
   TRANSACTION_NO_SUPPORT=\
       In &lt;transaction&gt;, datasource does not support transactions
   
  @@ -173,7 +170,7 @@
       It is illegal to specify a DataSource when nested within a &lt;transaction&gt;
   
   SQL_PARAM_OUTSIDE_PARENT=\
  -    lt;param&gt; outside &lt;query&gt; or &lt;update&gt;
  +    &lt;param&gt; or &lt;dateParam&gt; must be subtag of SQLExecutionTag
actions like &lt;query&gt; or &lt;update&gt;
   
   SQL_NO_STATEMENT=\
       No SQL statement specified
  
  
  
  1.4       +7 -1      jakarta-taglibs/standard/src/org/apache/taglibs/standard/tlv/JstlSqlTLV.java
  
  Index: JstlSqlTLV.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/tlv/JstlSqlTLV.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- JstlSqlTLV.java	11 Apr 2002 01:00:08 -0000	1.3
  +++ JstlSqlTLV.java	14 Apr 2002 02:10:31 -0000	1.4
  @@ -81,6 +81,7 @@
       private final String UPDATE = "update";
       private final String TRANSACTION = "transaction";
       private final String PARAM = "param";
  +    private final String DATEPARAM = "dateParam";
   
       private final String JSP_TEXT = "jsp:text";
   
  @@ -168,7 +169,8 @@
                *   </c:forEach>
                *  </sql:query>
                */
  -            if (isTag(qn, PARAM) && (queryDepths.empty() && updateDepths.empty())
) {
  +            if ( (isTag(qn, PARAM) || isTag(qn, DATEPARAM)) 
  +                && (queryDepths.empty() && updateDepths.empty()) ) {
                   fail(Resources.getMessage("SQL_PARAM_OUTSIDE_PARENT"));
               }
   
  @@ -196,6 +198,10 @@
                   if (hasAttribute(a, DATASOURCE) && !transactionDepths.empty())
{
                       fail(Resources.getMessage("ERROR_NESTED_DATASOURCE"));
                   }
  +            }
  +
  +            if (isTag(qn, DATEPARAM)) {
  +                bodyIllegal = true;
               }
   
   	    // record the most recent tag (for error reporting)
  
  
  
  1.13      +24 -1     jakarta-taglibs/standard/conf/sql-rt.tld
  
  Index: sql-rt.tld
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/conf/sql-rt.tld,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- sql-rt.tld	12 Apr 2002 22:20:08 -0000	1.12
  +++ sql-rt.tld	14 Apr 2002 02:10:31 -0000	1.13
  @@ -32,6 +32,10 @@
           <required>false</required>
           <rtexprvalue>true</rtexprvalue>
       </attribute>
  +    <attribute>
  +        <name>isolation</name>
  +        <required>false</required>
  +        <rtexprvalue>true</rtexprvalue>
     </tag>
   
     <tag>
  @@ -119,6 +123,25 @@
     </tag>
   
     <tag>
  +    <name>dateParam</name>
  +    <tag-class>org.apache.taglibs.standard.tag.rt.sql.DateParamTag</tag-class>
  +    <body-content>JSP</body-content>
  +    <description>
  +        Sets a parameter in an SQL statement to the specified java.util.Date value.
  +    </description>
  +    <attribute>
  +        <name>value</name>
  +        <required>true</required>
  +        <rtexprvalue>true</rtexprvalue>
  +    </attribute>
  +    <attribute>
  +        <name>type</name>
  +        <required>false</required>
  +        <rtexprvalue>true</rtexprvalue>
  +    </attribute>
  +  </tag>
  +
  +  <tag>
       <name>setDriver</name>
       <tag-class>org.apache.taglibs.standard.tag.common.sql.DriverTag</tag-class>
       <body-content>empty</body-content>
  @@ -127,7 +150,7 @@
       </description>
       <attribute>
           <name>var</name>
  -        <required>true</required>
  +        <required>false</required>
           <rtexprvalue>false</rtexprvalue>
       </attribute>
       <attribute>
  
  
  
  1.15      +22 -0     jakarta-taglibs/standard/conf/sql.tld
  
  Index: sql.tld
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/conf/sql.tld,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- sql.tld	12 Apr 2002 22:20:08 -0000	1.14
  +++ sql.tld	14 Apr 2002 02:10:31 -0000	1.15
  @@ -26,6 +26,8 @@
           update:sql
           update:dataSource
           param:value
  +        dateParam:value
  +        dateParam:type
           setDriver:driver
           setDriver:url
           setDriver:user
  @@ -144,6 +146,26 @@
           <name>value</name>
           <required>false</required>
           <rtexprvalue>false</rtexprvalue>
  +    </attribute>
  +  </tag>
  +
  +  <tag>
  +    <name>dateParam</name>
  +    <tag-class>org.apache.taglibs.standard.tag.rt.sql.DateParamTag</tag-class>
  +    <body-content>JSP</body-content>
  +    <description>
  +        Sets a parameter in an SQL statement to the specified java.util.Date val
  +ue.
  +    </description>
  +    <attribute>
  +        <name>value</name>
  +        <required>true</required>
  +        <rtexprvalue>true</rtexprvalue>
  +    </attribute>
  +    <attribute>
  +        <name>type</name>
  +        <required>false</required>
  +        <rtexprvalue>true</rtexprvalue>
       </attribute>
     </tag>
   
  
  
  

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