dmkarr      2002/10/25 22:24:44

  Modified:    contrib/struts-el/src/share/org/apache/strutsel/taglib/html
                        ELJavascriptValidatorTag.java
               contrib/struts-el/doc/userGuide struts-html-el.xml
  Added:       contrib/struts-el/src/share/org/apache/strutsel/taglib/html
                        ELJavascriptValidatorTagBeanInfo.java
  Log:
  Bug 13985; Adding htmlComment attribute to html-el:javascript tag, also made page 
attribute check for null string
  
  Revision  Changes    Path
  1.4       +46 -9     
jakarta-struts/contrib/struts-el/src/share/org/apache/strutsel/taglib/html/ELJavascriptValidatorTag.java
  
  Index: ELJavascriptValidatorTag.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-struts/contrib/struts-el/src/share/org/apache/strutsel/taglib/html/ELJavascriptValidatorTag.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ELJavascriptValidatorTag.java     1 Oct 2002 04:25:50 -0000       1.3
  +++ ELJavascriptValidatorTag.java     26 Oct 2002 05:24:44 -0000      1.4
  @@ -62,7 +62,7 @@
   
   import org.apache.struts.taglib.html.JavascriptValidatorTag;
   import javax.servlet.jsp.JspException;
  -import org.apache.taglibs.standard.tag.el.core.ExpressionUtil;
  +import org.apache.strutsel.taglib.utils.EvalHelper;
   import org.apache.taglibs.standard.tag.common.core.NullAttributeException;
   
   /**
  @@ -82,6 +82,33 @@
   public class ELJavascriptValidatorTag extends JavascriptValidatorTag {
   
       /**
  +     * String value of the "page" attribute.
  +     */
  +    private String   pageExpr;
  +
  +    /**
  +     * Returns the string value of the "page" attribute.
  +     */
  +    public  String   getPageExpr() { return (pageExpr); }
  +
  +    /**
  +     * Sets the string value of the "page" attribute.  This attribute is mapped
  +     * to this method by the <code>ELJavascriptValidatorTagBeanInfo</code>
  +     * class.
  +     */
  +    public  void     setPageExpr(String pageExpr)
  +    { this.pageExpr  = pageExpr; }
  +
  +    /**
  +     * Resets attribute values for tag reuse.
  +     */
  +    public void release()
  +    {
  +        super.release();
  +        setPageExpr(null);
  +    }
  +
  +    /**
        * Process the start tag.
        *
        * @exception JspException if a JSP exception has occurred
  @@ -93,7 +120,8 @@
       
       /**
        * Evaluates and returns a single attribute value, given the attribute
  -     * name, attribute value, and attribute type.  It uses
  +     * name, attribute value, and attribute type.  It uses the
  +     * <code>EvalHelper</code> class to interface to
        * <code>ExpressionUtil.evalNotNull</code> to do the actual evaluation, and
        * it passes to this the name of the current tag, the <code>this</code>
        * pointer, and the current pageContext.
  @@ -101,6 +129,8 @@
        * @param attrName attribute name being evaluated
        * @param attrValue String value of attribute to be evaluated using EL
        * @param attrType Required resulting type of attribute value
  +     * @exception NullAttributeException if either the <code>attrValue</code>
  +     * was null, or the resulting evaluated value was null.
        * @return Resulting attribute value
        */
       private Object   evalAttr(String   attrName,
  @@ -108,8 +138,8 @@
                                 Class    attrType)
           throws JspException, NullAttributeException
       {
  -        return (ExpressionUtil.evalNotNull("javascript", attrName, attrValue,
  -                                           attrType, this, pageContext));
  +        return (EvalHelper.eval("javascript", attrName, attrValue, attrType,
  +                                this, pageContext));
       }
       
       /**
  @@ -143,7 +173,7 @@
           }
   
           try {
  -            setPage(((Integer) evalAttr("page", getPage() + "", Integer.class)).
  +            setPage(((Integer) evalAttr("page", getPageExpr(), Integer.class)).
                       intValue());
           } catch (NullAttributeException ex) {
               setPage(0);
  @@ -161,6 +191,13 @@
                                                     String.class));
           } catch (NullAttributeException ex) {
               setStaticJavascript(null);
  +        }
  +
  +        try {
  +            setHtmlComment((String) evalAttr("htmlComment", getHtmlComment(),
  +                                             String.class));
  +        } catch (NullAttributeException ex) {
  +            setHtmlComment(null);
           }
       }
   }
  
  
  
  1.1                  
jakarta-struts/contrib/struts-el/src/share/org/apache/strutsel/taglib/html/ELJavascriptValidatorTagBeanInfo.java
  
  Index: ELJavascriptValidatorTagBeanInfo.java
  ===================================================================
  /*
   * $Header: 
/home/cvs/jakarta-struts/contrib/struts-el/src/share/org/apache/strutsel/taglib/html/ELJavascriptValidatorTagBeanInfo.java,v
 1.1 2002/10/26 05:24:44 dmkarr Exp $
   * $Revision: 1.1 $
   * $Date: 2002/10/26 05:24:44 $
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 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 acknowledgement:
   *       "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", "Struts", 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 [EMAIL PROTECTED]
   *
   * 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.strutsel.taglib.html;
  
  import java.beans.PropertyDescriptor;
  import java.beans.IntrospectionException;
  import java.beans.SimpleBeanInfo;
  
  /**
   * This is the <code>BeanInfo</code> descriptor for the
   * <code>org.apache.strutsel.taglib.html.ELJavascriptValidatorTag</code> class.
   * It is needed to override the default mapping of custom tag attribute names
   * to class attribute names.
   *<p>
   * This is necessary because the base class,
   * <code>org.apache.struts.taglib.html.JavascriptValidatorTag</code> defines
   * some attributes whose type is not <code>java.lang.String</code>, so the
   * subclass needs to define setter methods of a different name, which this
   * class maps to.
   *<p>
   * Unfortunately, if a <code>BeanInfo</code> class needs to be provided to
   * change the mapping of one attribute, it has to specify the mappings of ALL
   * attributes, even if all the others use the expected mappings of "name" to
   * "method".
   */
  public class ELJavascriptValidatorTagBeanInfo extends SimpleBeanInfo
  {
      public  PropertyDescriptor[] getPropertyDescriptors()
      {
          PropertyDescriptor[]  result   = new PropertyDescriptor[7];
  
          try {
              result[0] = new PropertyDescriptor("dynamicJavascript",
                                                 ELJavascriptValidatorTag.class,
                                                 null, "setDynamicJavascript");
              result[1] = new PropertyDescriptor("formName",
                                                 ELJavascriptValidatorTag.class,
                                                 null, "setFormName");
              result[2] = new PropertyDescriptor("method",
                                                 ELJavascriptValidatorTag.class,
                                                 null, "setMethod");
              result[3] = new PropertyDescriptor("page",
                                                 ELJavascriptValidatorTag.class,
                                                 null, "setPageExpr");
              result[4] = new PropertyDescriptor("src",
                                                 ELJavascriptValidatorTag.class,
                                                 null, "setSrc");
              result[5] = new PropertyDescriptor("staticJavascript",
                                                 ELJavascriptValidatorTag.class,
                                                 null, "setStaticJavascript");
              result[6] = new PropertyDescriptor("htmlComment",
                                                 ELJavascriptValidatorTag.class,
                                                 null, "setHtmlComment");
          }
          catch (IntrospectionException ex) {
              ex.printStackTrace();
          }
          
          return (result);
      }
  }
  
  
  
  1.5       +12 -0     
jakarta-struts/contrib/struts-el/doc/userGuide/struts-html-el.xml
  
  Index: struts-html-el.xml
  ===================================================================
  RCS file: 
/home/cvs/jakarta-struts/contrib/struts-el/doc/userGuide/struts-html-el.xml,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- struts-html-el.xml        14 Oct 2002 03:16:39 -0000      1.4
  +++ struts-html-el.xml        26 Oct 2002 05:24:44 -0000      1.5
  @@ -2975,6 +2975,18 @@
                  </p>
               </info>
           </attribute>
  +        <attribute>
  +            <name>htmlComment</name>
  +            <required>false</required>
  +            <rtexprvalue>false</rtexprvalue>
  +            <info>
  +               <p>
  +                  Wheather or not to enclose the javascript
  +                  with html comments.
  +                  Defaults to <code>true</code>.
  +               </p>
  +            </info>
  +        </attribute>
   
       </tag>
   
  
  
  

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

Reply via email to