dmkarr      2002/10/14 20:12:41

  Modified:    contrib/struts-el/src/share/org/apache/strutsel/taglib/html
                        ELResetTag.java ELRewriteTag.java
               contrib/struts-el/web/exercise-taglib html-button.jsp
  Added:       contrib/struts-el/src/share/org/apache/strutsel/taglib/html
                        ELResetTagBeanInfo.java ELRewriteTagBeanInfo.java
  Log:
  More boolean mapping fixes, and exercise test for reset tag
  
  Revision  Changes    Path
  1.4       +38 -9     
jakarta-struts/contrib/struts-el/src/share/org/apache/strutsel/taglib/html/ELResetTag.java
  
  Index: ELResetTag.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-struts/contrib/struts-el/src/share/org/apache/strutsel/taglib/html/ELResetTag.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ELResetTag.java   1 Oct 2002 04:25:50 -0000       1.3
  +++ ELResetTag.java   15 Oct 2002 03:12:41 -0000      1.4
  @@ -62,7 +62,7 @@
   
   import org.apache.struts.taglib.html.ResetTag;
   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;
   
   /**
  @@ -80,6 +80,32 @@
   public class ELResetTag extends ResetTag {
   
       /**
  +     * String value of the "disabled" attribute.
  +     */
  +    private String   disabledExpr;
  +
  +    /**
  +     * Returns the string value of the "disabled" attribute.
  +     */
  +    public  String   getDisabledExpr() { return (disabledExpr); }
  +
  +    /**
  +     * Sets the string value of the "disabled" attribute.  This attribute is
  +     * mapped to this method by the <code>ELResetTagBeanInfo</code> class.
  +     */
  +    public  void     setDisabledExpr(String disabledExpr)
  +    { this.disabledExpr  = disabledExpr; }
  +
  +    /**
  +     * Resets attribute values for tag reuse.
  +     */
  +    public void release()
  +    {
  +        super.release();
  +        setDisabledExpr(null);
  +    }
  +
  +    /**
        * Process the start tag.
        *
        * @exception JspException if a JSP exception has occurred
  @@ -91,7 +117,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.
  @@ -99,6 +126,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,
  @@ -106,8 +135,8 @@
                                 Class    attrType)
           throws JspException, NullAttributeException
       {
  -        return (ExpressionUtil.evalNotNull("reset", attrName, attrValue,
  -                                           attrType, this, pageContext));
  +        return (EvalHelper.eval("reset", attrName, attrValue, attrType,
  +                                this, pageContext));
       }
       
       /**
  @@ -139,7 +168,7 @@
           }
   
           try {
  -            setDisabled(((Boolean) evalAttr("disabled", getDisabled() + "",
  +            setDisabled(((Boolean) evalAttr("disabled", getDisabledExpr(),
                                               Boolean.class)).
                           booleanValue());
           } catch (NullAttributeException ex) {
  
  
  
  1.4       +38 -9     
jakarta-struts/contrib/struts-el/src/share/org/apache/strutsel/taglib/html/ELRewriteTag.java
  
  Index: ELRewriteTag.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-struts/contrib/struts-el/src/share/org/apache/strutsel/taglib/html/ELRewriteTag.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ELRewriteTag.java 1 Oct 2002 04:25:50 -0000       1.3
  +++ ELRewriteTag.java 15 Oct 2002 03:12:41 -0000      1.4
  @@ -62,7 +62,7 @@
   
   import org.apache.struts.taglib.html.RewriteTag;
   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;
   
   /**
  @@ -80,6 +80,32 @@
   public class ELRewriteTag extends RewriteTag {
   
       /**
  +     * String value of the "transaction" attribute.
  +     */
  +    private String   transactionExpr;
  +
  +    /**
  +     * Returns the string value of the "transaction" attribute.
  +     */
  +    public  String   getTransactionExpr() { return (transactionExpr); }
  +
  +    /**
  +     * Sets the string value of the "transaction" attribute.  This attribute is
  +     * mapped to this method by the <code>ELRewriteTagBeanInfo</code> class.
  +     */
  +    public  void     setTransactionExpr(String transactionExpr)
  +    { this.transactionExpr  = transactionExpr; }
  +
  +    /**
  +     * Resets attribute values for tag reuse.
  +     */
  +    public void release()
  +    {
  +        super.release();
  +        setTransactionExpr(null);
  +    }
  +
  +    /**
        * Process the start tag.
        *
        * @exception JspException if a JSP exception has occurred
  @@ -91,7 +117,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.
  @@ -99,6 +126,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,
  @@ -106,8 +135,8 @@
                                 Class    attrType)
           throws JspException, NullAttributeException
       {
  -        return (ExpressionUtil.evalNotNull("rewrite", attrName, attrValue,
  -                                           attrType, this, pageContext));
  +        return (EvalHelper.eval("rewrite", attrName, attrValue, attrType,
  +                                this, pageContext));
       }
       
       /**
  @@ -194,7 +223,7 @@
   
           try {
               setTransaction(((Boolean) evalAttr("transaction",
  -                                               getTransaction() + "", 
  +                                               getTransactionExpr(), 
                                                  Boolean.class)).
                              booleanValue());
           } catch (NullAttributeException ex) {
  
  
  
  1.1                  
jakarta-struts/contrib/struts-el/src/share/org/apache/strutsel/taglib/html/ELResetTagBeanInfo.java
  
  Index: ELResetTagBeanInfo.java
  ===================================================================
  /*
   * $Header: 
/home/cvs/jakarta-struts/contrib/struts-el/src/share/org/apache/strutsel/taglib/html/ELResetTagBeanInfo.java,v
 1.1 2002/10/15 03:12:41 dmkarr Exp $
   * $Revision: 1.1 $
   * $Date: 2002/10/15 03:12:41 $
   * ====================================================================
   *
   * 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.ELResetTag</code> class.  It is needed
   * to override the default mapping of custom tag attribute names to class
   * attribute names.
   *<p>
   * In particular, it provides for the mapping of the custom tag attribute
   * <code>disabled</code> to the instance variable <code>disabledExpr</code>.
   *<p>
   * This is necessary because the base class,
   * <code>org.apache.struts.taglib.html.ResetTag</code> already defines this
   * attribute, of type <code>boolean</code>, and the <code>ELResetTag</code>
   * class has to be able to see this values as a <code>String</code> type in
   * order to evaluate it with the JSTL EL engine.
   *<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 ELResetTagBeanInfo extends SimpleBeanInfo
  {
      public  PropertyDescriptor[] getPropertyDescriptors()
      {
          PropertyDescriptor[]  result   = new PropertyDescriptor[25];
  
          try {
              result[0] = new PropertyDescriptor("accesskey", ELResetTag.class,
                                                 null, "setAccesskey");
              result[1] = new PropertyDescriptor("alt", ELResetTag.class,
                                                 null, "setAlt");
              result[2] = new PropertyDescriptor("altKey", ELResetTag.class,
                                                 null, "setAltKey");
              // This attribute has a non-standard mapping.
              result[3] = new PropertyDescriptor("disabled", ELResetTag.class,
                                                 null, "setDisabledExpr");
              result[4] = new PropertyDescriptor("onblur", ELResetTag.class,
                                                 null, "setOnblur");
              result[5] = new PropertyDescriptor("onchange", ELResetTag.class,
                                                 null, "setOnchange");
              result[6] = new PropertyDescriptor("onclick", ELResetTag.class,
                                                 null, "setOnclick");
              result[7] = new PropertyDescriptor("ondblclick",
                                                 ELResetTag.class,
                                                 null, "setOndblclick");
              result[8] = new PropertyDescriptor("onfocus", ELResetTag.class,
                                                 null, "setOnfocus");
              result[9] = new PropertyDescriptor("onkeydown",
                                                  ELResetTag.class,
                                                 null, "setOnkeydown");
              result[10] = new PropertyDescriptor("onkeypress",
                                                  ELResetTag.class,
                                                 null, "setOnkeypress");
              result[11] = new PropertyDescriptor("onkeyup", ELResetTag.class,
                                                 null, "setOnkeyup");
              result[12] = new PropertyDescriptor("onmousedown",
                                                 ELResetTag.class,
                                                 null, "setOnmousedown");
              result[13] = new PropertyDescriptor("onmousemove",
                                                 ELResetTag.class,
                                                 null, "setOnmousemove");
              result[14] = new PropertyDescriptor("onmouseout",
                                                 ELResetTag.class,
                                                 null, "setOnmouseout");
              result[15] = new PropertyDescriptor("onmouseover",
                                                 ELResetTag.class,
                                                 null, "setOnmouseover");
              result[16] = new PropertyDescriptor("onmouseup",
                                                  ELResetTag.class,
                                                 null, "setOnmouseup");
              result[17] = new PropertyDescriptor("property", ELResetTag.class,
                                                 null, "setProperty");
              result[18] = new PropertyDescriptor("style", ELResetTag.class,
                                                 null, "setStyle");
              result[19] = new PropertyDescriptor("styleClass",
                                                 ELResetTag.class,
                                                 null, "setStyleClass");
              result[20] = new PropertyDescriptor("styleId", ELResetTag.class,
                                                 null, "setStyleId");
              result[21] = new PropertyDescriptor("tabindex", ELResetTag.class,
                                                 null, "setTabindex");
              result[22] = new PropertyDescriptor("title", ELResetTag.class,
                                                 null, "setTitle");
              result[23] = new PropertyDescriptor("titleKey", ELResetTag.class,
                                                 null, "setTitleKey");
              result[24] = new PropertyDescriptor("value", ELResetTag.class,
                                                 null, "setValue");
          }
          catch (IntrospectionException ex) {
              ex.printStackTrace();
          }
          
          return (result);
      }
  }
  
  
  
  1.1                  
jakarta-struts/contrib/struts-el/src/share/org/apache/strutsel/taglib/html/ELRewriteTagBeanInfo.java
  
  Index: ELRewriteTagBeanInfo.java
  ===================================================================
  /*
   * $Header: 
/home/cvs/jakarta-struts/contrib/struts-el/src/share/org/apache/strutsel/taglib/html/ELRewriteTagBeanInfo.java,v
 1.1 2002/10/15 03:12:41 dmkarr Exp $
   * $Revision: 1.1 $
   * $Date: 2002/10/15 03:12:41 $
   * ====================================================================
   *
   * 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.ELRewriteTag</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.RewriteTag</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 ELRewriteTagBeanInfo extends SimpleBeanInfo
  {
      public  PropertyDescriptor[] getPropertyDescriptors()
      {
          PropertyDescriptor[]  result   = new PropertyDescriptor[12];
  
          try {
              result[0] = new PropertyDescriptor("anchor", ELRewriteTag.class,
                                                 null, "setAnchor");
              result[1] = new PropertyDescriptor("forward", ELRewriteTag.class,
                                                 null, "setForward");
              result[2] = new PropertyDescriptor("href", ELRewriteTag.class,
                                                 null, "setHref");
              result[3] = new PropertyDescriptor("name", ELRewriteTag.class,
                                                 null, "setName");
              result[4] = new PropertyDescriptor("page", ELRewriteTag.class,
                                                  null, "setPage");
              result[5] = new PropertyDescriptor("paramId", ELRewriteTag.class,
                                                  null, "setParamId");
              result[6] = new PropertyDescriptor("paramName", ELRewriteTag.class,
                                                  null, "setParamName");
              result[7] = new PropertyDescriptor("paramProperty",
                                                  ELRewriteTag.class,
                                                  null, "setParamProperty");
              result[8] = new PropertyDescriptor("paramScope",
                                                  ELRewriteTag.class,
                                                  null, "setParamScope");
              result[9] = new PropertyDescriptor("property", ELRewriteTag.class,
                                                  null, "setProperty");
              result[10] = new PropertyDescriptor("scope", ELRewriteTag.class,
                                                  null, "setScope");
              result[11] = new PropertyDescriptor("transaction",
                                                  ELRewriteTag.class,
                                                  null, "setTransactionExpr");
          }
          catch (IntrospectionException ex) {
              ex.printStackTrace();
          }
          
          return (result);
      }
  }
  
  
  
  1.2       +10 -0     
jakarta-struts/contrib/struts-el/web/exercise-taglib/html-button.jsp
  
  Index: html-button.jsp
  ===================================================================
  RCS file: 
/home/cvs/jakarta-struts/contrib/struts-el/web/exercise-taglib/html-button.jsp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- html-button.jsp   14 Oct 2002 03:11:09 -0000      1.1
  +++ html-button.jsp   15 Oct 2002 03:12:41 -0000      1.2
  @@ -60,6 +60,16 @@
         <html-el:cancel property="stringProperty" disabled="${!empty pageScope}"/>
        </td>
       </tr>
  +    <tr>
  +     <td>
  +      <html-el:reset property="stringProperty" />
  +     </td>
  +    </tr>
  +    <tr>
  +     <td>
  +      <html-el:reset property="stringProperty" disabled="${!empty pageScope}"/>
  +     </td>
  +    </tr>
      </table>
     </html-el:form>
     <script>
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to