You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by cr...@locus.apache.org on 2000/06/15 03:27:45 UTC

cvs commit: jakarta-struts/src/share/org/apache/struts/taglib BaseHandlerTag.java ButtonTag.java BaseFieldTag.java BaseInputTag.java CheckboxTag.java FormTag.java PropertyTag.java RadioTag.java ResetTag.java SelectTag.java SubmitTag.java

craigmcc    00/06/14 18:27:43

  Modified:    src/share/org/apache/struts/action ActionServlet.java
               src/share/org/apache/struts/taglib BaseFieldTag.java
                        BaseInputTag.java CheckboxTag.java FormTag.java
                        PropertyTag.java RadioTag.java ResetTag.java
                        SelectTag.java SubmitTag.java
  Added:       src/share/org/apache/struts/taglib BaseHandlerTag.java
                        ButtonTag.java
  Log:
  Add the new <struts:button> custom tag, and the corresponding base class,
  contributed by Don Clasen.  In addition, refactor most of the other input
  tags to inherit from BaseHandlerClass so that they can be event-enabled
  as well.
  
  I have not yet modified the TLD (or the documentation) to reflect the new
  attributes.  That is the next step.
  
  Revision  Changes    Path
  1.5       +6 -5      jakarta-struts/src/share/org/apache/struts/action/ActionServlet.java
  
  Index: ActionServlet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/action/ActionServlet.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ActionServlet.java	2000/06/13 02:40:29	1.4
  +++ ActionServlet.java	2000/06/15 01:27:30	1.5
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/action/ActionServlet.java,v 1.4 2000/06/13 02:40:29 craigmcc Exp $
  - * $Revision: 1.4 $
  - * $Date: 2000/06/13 02:40:29 $
  + * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/action/ActionServlet.java,v 1.5 2000/06/15 01:27:30 craigmcc Exp $
  + * $Revision: 1.5 $
  + * $Date: 2000/06/15 01:27:30 $
    *
    * ====================================================================
    *
  @@ -140,7 +140,7 @@
    * <p>
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.4 $ $Date: 2000/06/13 02:40:29 $
  + * @version $Revision: 1.5 $ $Date: 2000/06/15 01:27:30 $
    */
   
   public class ActionServlet
  @@ -239,7 +239,8 @@
   	// Load our internationalized resource bundle
   	internal = MessageResources.getMessageResources(internalName);
   	if (internal == null)
  -	    throw new UnavailableException("Cannot load internal resources");
  +	    throw new UnavailableException("Cannot load internal resources from '"
  +	                                   + internalName + "'");
   
   	// Process our servlet initialization parameters
   	String value;
  
  
  
  1.2       +9 -6      jakarta-struts/src/share/org/apache/struts/taglib/BaseFieldTag.java
  
  Index: BaseFieldTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/BaseFieldTag.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BaseFieldTag.java	2000/05/31 22:28:11	1.1
  +++ BaseFieldTag.java	2000/06/15 01:27:32	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/BaseFieldTag.java,v 1.1 2000/05/31 22:28:11 craigmcc Exp $
  - * $Revision: 1.1 $
  - * $Date: 2000/05/31 22:28:11 $
  + * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/BaseFieldTag.java,v 1.2 2000/06/15 01:27:32 craigmcc Exp $
  + * $Revision: 1.2 $
  + * $Date: 2000/06/15 01:27:32 $
    *
    * ====================================================================
    *
  @@ -77,10 +77,10 @@
    * Convenience base class for the various input tags for text fields.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.1 $ $Date: 2000/05/31 22:28:11 $
  + * @version $Revision: 1.2 $ $Date: 2000/06/15 01:27:32 $
    */
   
  -public class BaseFieldTag extends BaseInputTag {
  +public abstract class BaseFieldTag extends BaseInputTag {
   
   
       // ----------------------------------------------------- Instance Variables
  @@ -146,7 +146,10 @@
   					 methodName, e.toString()));
   	    }
   	}
  -	results.append("\">");
  +	results.append("\"");
  +	results.append(prepareEventHandlers());
  +	results.append(prepareStyles());
  +	results.append(">");
   
   	// Print this field to our output writer
   	JspWriter writer = pageContext.getOut();
  @@ -158,7 +161,7 @@
   	}
   
   	// Continue processing this page
  -	return (EVAL_BODY_INCLUDE);
  +	return (EVAL_BODY_TAG);
   
       }
   
  
  
  
  1.2       +5 -5      jakarta-struts/src/share/org/apache/struts/taglib/BaseInputTag.java
  
  Index: BaseInputTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/BaseInputTag.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BaseInputTag.java	2000/05/31 22:28:11	1.1
  +++ BaseInputTag.java	2000/06/15 01:27:34	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/BaseInputTag.java,v 1.1 2000/05/31 22:28:11 craigmcc Exp $
  - * $Revision: 1.1 $
  - * $Date: 2000/05/31 22:28:11 $
  + * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/BaseInputTag.java,v 1.2 2000/06/15 01:27:34 craigmcc Exp $
  + * $Revision: 1.2 $
  + * $Date: 2000/06/15 01:27:34 $
    *
    * ====================================================================
    *
  @@ -74,10 +74,10 @@
    * Abstract base class for the various input tags.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.1 $ $Date: 2000/05/31 22:28:11 $
  + * @version $Revision: 1.2 $ $Date: 2000/06/15 01:27:34 $
    */
   
  -public class BaseInputTag extends TagSupport {
  +public abstract class BaseInputTag extends BaseHandlerTag {
   
   
       // ----------------------------------------------------- Instance Variables
  @@ -329,7 +329,7 @@
        */
       public int doStartTag() throws JspException {
   
  -	return (EVAL_BODY_INCLUDE);
  +	return (EVAL_BODY_TAG);
   
       }
   
  
  
  
  1.3       +7 -6      jakarta-struts/src/share/org/apache/struts/taglib/CheckboxTag.java
  
  Index: CheckboxTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/CheckboxTag.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- CheckboxTag.java	2000/06/12 16:00:53	1.2
  +++ CheckboxTag.java	2000/06/15 01:27:34	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/CheckboxTag.java,v 1.2 2000/06/12 16:00:53 craigmcc Exp $
  - * $Revision: 1.2 $
  - * $Date: 2000/06/12 16:00:53 $
  + * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/CheckboxTag.java,v 1.3 2000/06/15 01:27:34 craigmcc Exp $
  + * $Revision: 1.3 $
  + * $Date: 2000/06/15 01:27:34 $
    *
    * ====================================================================
    *
  @@ -68,7 +68,6 @@
   import javax.servlet.jsp.JspException;
   import javax.servlet.jsp.PageContext;
   import javax.servlet.jsp.JspWriter;
  -import javax.servlet.jsp.tagext.BodyTagSupport;
   import org.apache.struts.util.BeanUtils;
   import org.apache.struts.util.MessageResources;
   
  @@ -77,10 +76,10 @@
    * Tag for input fields of type "checkbox".
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.2 $ $Date: 2000/06/12 16:00:53 $
  + * @version $Revision: 1.3 $ $Date: 2000/06/15 01:27:34 $
    */
   
  -public final class CheckboxTag extends BodyTagSupport {
  +public final class CheckboxTag extends BaseHandlerTag {
   
   
       // ----------------------------------------------------- Instance Variables
  @@ -193,6 +192,8 @@
   	}
   	if (value.equalsIgnoreCase("true") || value.equalsIgnoreCase("yes"))
   	    results.append(" checked");
  +	results.append(prepareEventHandlers());
  +	results.append(prepareStyles());
   	results.append(">");
   
   	// Print this field to our output writer
  
  
  
  1.2       +69 -3     jakarta-struts/src/share/org/apache/struts/taglib/FormTag.java
  
  Index: FormTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/FormTag.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- FormTag.java	2000/05/31 22:28:12	1.1
  +++ FormTag.java	2000/06/15 01:27:34	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/FormTag.java,v 1.1 2000/05/31 22:28:12 craigmcc Exp $
  - * $Revision: 1.1 $
  - * $Date: 2000/05/31 22:28:12 $
  + * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/FormTag.java,v 1.2 2000/06/15 01:27:34 craigmcc Exp $
  + * $Revision: 1.2 $
  + * $Date: 2000/06/15 01:27:34 $
    *
    * ====================================================================
    *
  @@ -78,7 +78,7 @@
    * properties correspond to the various fields of the form.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.1 $ $Date: 2000/05/31 22:28:12 $
  + * @version $Revision: 1.2 $ $Date: 2000/06/15 01:27:34 $
    */
   
   public final class FormTag extends TagSupport {
  @@ -114,6 +114,18 @@
   
   
       /**
  +     * The onReset event script.
  +     */
  +    private String onReset = null;
  +
  +
  +    /**
  +     * The onSubmit event script.
  +     */
  +    private String onSubmit = null;
  +
  +
  +    /**
        * The scope (request or session) under which our associated bean
        * is stored.
        */
  @@ -196,6 +208,50 @@
   
   
       /**
  +     * Return the onReset event script.
  +     */
  +    public String getOnReset() {
  +
  +	return (this.onReset);
  +
  +    }
  +
  +
  +    /**
  +     * Set the onReset event script.
  +     *
  +     * @param onReset The new event script
  +     */
  +    public void setOnReset(String onReset) {
  +
  +	this.onReset = onReset;
  +
  +    }
  +
  +
  +    /**
  +     * Return the onSubmit event script.
  +     */
  +    public String getOnSubmit() {
  +
  +	return (this.onSubmit);
  +
  +    }
  +
  +
  +    /**
  +     * Set the onSubmit event script.
  +     *
  +     * @param onSubmit The new event script
  +     */
  +    public void setOnSubmit(String onSubmit) {
  +
  +	this.onSubmit = onSubmit;
  +
  +    }
  +
  +
  +    /**
        * Return the attribute scope of our bean.
        */
       public String getScope() {
  @@ -259,6 +315,16 @@
   	if (action != null) {
   	    results.append(" action=\"");
   	    results.append(response.encodeURL(BeanUtils.filter(action)));
  +	    results.append("\"");
  +	}
  +	if (onReset != null) {
  +	    results.append(" onreset=\"");
  +	    results.append(onReset);
  +	    results.append("\"");
  +        }
  +        if (onSubmit != null) {
  +	    results.append(" onsubmit=\"");
  +	    results.append(onSubmit);
   	    results.append("\"");
   	}
   	results.append(">");
  
  
  
  1.2       +4 -4      jakarta-struts/src/share/org/apache/struts/taglib/PropertyTag.java
  
  Index: PropertyTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/PropertyTag.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PropertyTag.java	2000/05/31 22:28:12	1.1
  +++ PropertyTag.java	2000/06/15 01:27:35	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/PropertyTag.java,v 1.1 2000/05/31 22:28:12 craigmcc Exp $
  - * $Revision: 1.1 $
  - * $Date: 2000/05/31 22:28:12 $
  + * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/PropertyTag.java,v 1.2 2000/06/15 01:27:35 craigmcc Exp $
  + * $Revision: 1.2 $
  + * $Date: 2000/06/15 01:27:35 $
    *
    * ====================================================================
    *
  @@ -77,7 +77,7 @@
    * Display the value of the specified bean property as read-only HTML text.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.1 $ $Date: 2000/05/31 22:28:12 $
  + * @version $Revision: 1.2 $ $Date: 2000/06/15 01:27:35 $
    */
   
   public class PropertyTag extends BaseInputTag {
  @@ -132,7 +132,7 @@
   	}
   
   	// Continue processing this page
  -	return (EVAL_BODY_INCLUDE);
  +	return (EVAL_BODY_TAG);
   
       }
   
  
  
  
  1.3       +7 -6      jakarta-struts/src/share/org/apache/struts/taglib/RadioTag.java
  
  Index: RadioTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/RadioTag.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- RadioTag.java	2000/06/12 16:00:53	1.2
  +++ RadioTag.java	2000/06/15 01:27:35	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/RadioTag.java,v 1.2 2000/06/12 16:00:53 craigmcc Exp $
  - * $Revision: 1.2 $
  - * $Date: 2000/06/12 16:00:53 $
  + * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/RadioTag.java,v 1.3 2000/06/15 01:27:35 craigmcc Exp $
  + * $Revision: 1.3 $
  + * $Date: 2000/06/15 01:27:35 $
    *
    * ====================================================================
    *
  @@ -68,7 +68,6 @@
   import javax.servlet.jsp.JspException;
   import javax.servlet.jsp.PageContext;
   import javax.servlet.jsp.JspWriter;
  -import javax.servlet.jsp.tagext.BodyTagSupport;
   import org.apache.struts.util.BeanUtils;
   import org.apache.struts.util.MessageResources;
   
  @@ -77,10 +76,10 @@
    * Tag for input fields of type "radio".
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.2 $ $Date: 2000/06/12 16:00:53 $
  + * @version $Revision: 1.3 $ $Date: 2000/06/15 01:27:35 $
    */
   
  -public final class RadioTag extends BodyTagSupport {
  +public final class RadioTag extends BaseHandlerTag {
   
   
       // ----------------------------------------------------- Instance Variables
  @@ -195,6 +194,8 @@
   	results.append("\"");
   	if (value.equals(current))
   	    results.append(" checked");
  +	results.append(prepareEventHandlers());
  +	results.append(prepareStyles());
   	results.append(">");
   
   	// Print this field to our output writer
  
  
  
  1.2       +8 -6      jakarta-struts/src/share/org/apache/struts/taglib/ResetTag.java
  
  Index: ResetTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/ResetTag.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ResetTag.java	2000/05/31 22:28:12	1.1
  +++ ResetTag.java	2000/06/15 01:27:35	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/ResetTag.java,v 1.1 2000/05/31 22:28:12 craigmcc Exp $
  - * $Revision: 1.1 $
  - * $Date: 2000/05/31 22:28:12 $
  + * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/ResetTag.java,v 1.2 2000/06/15 01:27:35 craigmcc Exp $
  + * $Revision: 1.2 $
  + * $Date: 2000/06/15 01:27:35 $
    *
    * ====================================================================
    *
  @@ -68,7 +68,6 @@
   import javax.servlet.jsp.JspException;
   import javax.servlet.jsp.PageContext;
   import javax.servlet.jsp.JspWriter;
  -import javax.servlet.jsp.tagext.BodyTagSupport;
   import org.apache.struts.util.BeanUtils;
   import org.apache.struts.util.MessageResources;
   
  @@ -77,10 +76,10 @@
    * Tag for input fields of type "reset".
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.1 $ $Date: 2000/05/31 22:28:12 $
  + * @version $Revision: 1.2 $ $Date: 2000/06/15 01:27:35 $
    */
   
  -public final class ResetTag extends BodyTagSupport {
  +public final class ResetTag extends BaseHandlerTag {
   
   
       // ----------------------------------------------------- Instance Variables
  @@ -190,7 +189,10 @@
   	results.append(name);
   	results.append("\" value=\"");
   	results.append(label);
  -	results.append("\">");
  +	results.append("\"");
  +	results.append(prepareEventHandlers());
  +	results.append(prepareStyles());
  +	results.append(">");
   
   	// Render this element to our writer
   	JspWriter writer = pageContext.getOut();
  
  
  
  1.2       +7 -6      jakarta-struts/src/share/org/apache/struts/taglib/SelectTag.java
  
  Index: SelectTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/SelectTag.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SelectTag.java	2000/05/31 22:28:12	1.1
  +++ SelectTag.java	2000/06/15 01:27:36	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/SelectTag.java,v 1.1 2000/05/31 22:28:12 craigmcc Exp $
  - * $Revision: 1.1 $
  - * $Date: 2000/05/31 22:28:12 $
  + * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/SelectTag.java,v 1.2 2000/06/15 01:27:36 craigmcc Exp $
  + * $Revision: 1.2 $
  + * $Date: 2000/06/15 01:27:36 $
    *
    * ====================================================================
    *
  @@ -69,7 +69,6 @@
   import javax.servlet.jsp.JspException;
   import javax.servlet.jsp.JspWriter;
   import javax.servlet.jsp.PageContext;
  -import javax.servlet.jsp.tagext.TagSupport;
   import org.apache.struts.util.BeanUtils;
   import org.apache.struts.util.MessageResources;
   
  @@ -80,10 +79,10 @@
    * inside a form tag.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.1 $ $Date: 2000/05/31 22:28:12 $
  + * @version $Revision: 1.2 $ $Date: 2000/06/15 01:27:36 $
    */
   
  -public final class SelectTag extends TagSupport {
  +public final class SelectTag extends BaseHandlerTag {
   
   
       // ----------------------------------------------------- Instance Variables
  @@ -187,6 +186,8 @@
   	results.append(" name=\"");
   	results.append(name);
   	results.append("\"");
  +	results.append(prepareEventHandlers());
  +	results.append(prepareStyles());
   	results.append(">");
   
   	// Print this field to our output writer
  @@ -229,7 +230,7 @@
   	}
   
   	// Continue processing this page
  -	return (EVAL_BODY_INCLUDE);
  +	return (EVAL_BODY_TAG);
   
       }
   
  
  
  
  1.2       +8 -6      jakarta-struts/src/share/org/apache/struts/taglib/SubmitTag.java
  
  Index: SubmitTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/SubmitTag.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SubmitTag.java	2000/05/31 22:28:11	1.1
  +++ SubmitTag.java	2000/06/15 01:27:36	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/SubmitTag.java,v 1.1 2000/05/31 22:28:11 craigmcc Exp $
  - * $Revision: 1.1 $
  - * $Date: 2000/05/31 22:28:11 $
  + * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/SubmitTag.java,v 1.2 2000/06/15 01:27:36 craigmcc Exp $
  + * $Revision: 1.2 $
  + * $Date: 2000/06/15 01:27:36 $
    *
    * ====================================================================
    *
  @@ -68,7 +68,6 @@
   import javax.servlet.jsp.JspException;
   import javax.servlet.jsp.PageContext;
   import javax.servlet.jsp.JspWriter;
  -import javax.servlet.jsp.tagext.BodyTagSupport;
   import org.apache.struts.util.BeanUtils;
   import org.apache.struts.util.MessageResources;
   
  @@ -77,10 +76,10 @@
    * Tag for input fields of type "submit".
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.1 $ $Date: 2000/05/31 22:28:11 $
  + * @version $Revision: 1.2 $ $Date: 2000/06/15 01:27:36 $
    */
   
  -public final class SubmitTag extends BodyTagSupport {
  +public final class SubmitTag extends BaseHandlerTag {
   
   
       // ----------------------------------------------------- Instance Variables
  @@ -190,7 +189,10 @@
   	results.append(name);
   	results.append("\" value=\"");
   	results.append(label);
  -	results.append("\">");
  +	results.append("\"");
  +	results.append(prepareEventHandlers());
  +	results.append(prepareStyles());
  +	results.append(">");
   
   	// Render this element to our writer
   	JspWriter writer = pageContext.getOut();
  
  
  
  1.1                  jakarta-struts/src/share/org/apache/struts/taglib/BaseHandlerTag.java
  
  Index: BaseHandlerTag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/BaseHandlerTag.java,v 1.1 2000/06/15 01:27:34 craigmcc Exp $
   * $Revision: 1.1 $
   * $Date: 2000/06/15 01:27:34 $
   *
   * ====================================================================
   *
   * 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.struts.taglib;
  
  import javax.servlet.jsp.tagext.BodyTagSupport;
  import org.apache.struts.util.MessageResources;
  
  /**
   * Base class for tags that render form elements capable of including JavaScript
   * event handlers and/or CSS Style attributes. This class does not implement
   * the doStartTag() or doEndTag() methods. Subclasses should provide
   * appropriate implementations of these.
   *
   * @author Don Clasen
   * @version $Revision: 1.1 $ $Date: 2000/06/15 01:27:34 $
   */
  
  public abstract class BaseHandlerTag extends BodyTagSupport {
  
  
      // ----------------------------------------------------- Instance Variables
  
  
      /**
       * The message resources for this package.
       */
      protected static MessageResources messages =
  	MessageResources.getMessageResources
  	("org.apache.struts.taglib.LocalStrings");
  
  
  //  Mouse Events
  
      /** Mouse click event. */
      private String onClick = null;
  
      /** Mouse double click event. */
      private String onDblClick = null;
  
      /** Mouse over component event. */
      private String onMouseOver = null;
  
      /** Mouse exit component event. */
      private String onMouseOut = null;
  
      /** Mouse moved over component event. */
      private String onMouseMove = null;
  
      /** Mouse pressed on component event. */
      private String onMouseDown = null;
  
      /** Mouse released on component event. */
      private String onMouseUp = null;
  
  //  Keyboard Events
  
      /** Key down in component event. */
      private String onKeyDown = null;
  
      /** Key released in component event. */
      private String onKeyUp = null;
  
      /** Key down and up together in component event. */
      private String onKeyPress = null;
  
  // Text Events
  
      /** Text selected in component event. */
      private String onSelect = null;
  
      /** Content changed after component lost focus event. */
      private String onChange = null;
  
  // Focus Events
  
      /** Component lost focus event. */
      private String onBlur = null;
  
      /** Component has received focus event. */
      private String onFocus = null;
  
  // CSS Style Support
  
      /** Style attribute associated with component. */
      private String style = null;
  
      /** Named Style class associated with component. */
      private String styleClass = null;
  
      // ------------------------------------------------------------- Properties
  
  // Mouse Events
  
      /** Sets the onClick event handler. */
      public void setOnClick(String onClick) {
          this.onClick = onClick;
      }
  
      /** Returns the onClick event handler. */
      public String getOnClick() {
          return onClick;
      }
  
      /** Sets the onDblClick event handler. */
      public void setOnDblClick(String onDblClick) {
          this.onDblClick = onDblClick;
      }
  
      /** Returns the onDblClick event handler. */
      public String getOnDblClick() {
          return onDblClick;
      }
  
      /** Sets the onMouseDown event handler. */
      public void setOnMouseDown(String onMouseDown) {
          this.onMouseDown = onMouseDown;
      }
  
      /** Returns the onMouseDown event handler. */
      public String getOnMouseDown() {
          return onMouseDown;
      }
  
      /** Sets the onMouseUp event handler. */
      public void setOnMouseUp(String onMouseUp) {
          this.onMouseUp = onMouseUp;
      }
  
      /** Returns the onMouseUp event handler. */
      public String getOnMouseUp() {
          return onMouseUp;
      }
  
      /** Sets the onMouseMove event handler. */
      public void setOnMouseMove(String onMouseMove) {
          this.onMouseMove = onMouseMove;
      }
  
      /** Returns the onMouseMove event handler. */
      public String getOnMouseMove() {
          return onMouseMove;
      }
  
      /** Sets the onMouseOver event handler. */
      public void setOnMouseOver(String onMouseOver) {
          this.onMouseOver = onMouseOver;
      }
  
      /** Returns the onMouseOver event handler. */
      public String getOnMouseOver() {
          return onMouseOver;
      }
  
      /** Sets the onMouseOut event handler. */
      public void setOnMouseOut(String onMouseOut) {
          this.onMouseOut = onMouseOut;
      }
  
      /** Returns the onMouseOut event handler. */
      public String getOnMouseOut() {
          return onMouseOut;
      }
  
  // Keyboard Events
  
      /** Sets the onKeyDown event handler. */
      public void setOnKeyDown(String onKeyDown) {
          this.onKeyDown = onKeyDown;
      }
  
      /** Returns the onKeyDown event handler. */
      public String getOnKeyDown() {
          return onKeyDown;
      }
  
      /** Sets the onKeyUp event handler. */
      public void setOnKeyUp(String onKeyUp) {
          this.onKeyUp = onKeyUp;
      }
  
      /** Returns the onKeyUp event handler. */
      public String getOnKeyUp() {
          return onKeyUp;
      }
  
      /** Sets the onKeyPress event handler. */
      public void setOnKeyPress(String onKeyPress) {
          this.onKeyPress = onKeyPress;
      }
  
      /** Returns the onKeyPress event handler. */
      public String getOnKeyPress() {
          return onKeyPress;
      }
  
  // Text Events
  
      /** Sets the onChange event handler. */
      public void setOnChange(String onChange) {
          this.onChange = onChange;
      }
  
      /** Returns the onChange event handler. */
      public String getOnChange() {
          return onChange;
      }
  
      /** Sets the onSelect event handler. */
      public void setOnSelect(String onSelect) {
          this.onSelect = onSelect;
      }
  
      /** Returns the onSelect event handler. */
      public String getOnSelect() {
          return onSelect;
      }
  
  // Focus Events
  
      /** Sets the onBlur event handler. */
      public void setOnBlur(String onBlur) {
          this.onBlur = onBlur;
      }
  
      /** Returns the onBlur event handler. */
      public String getOnBlur() {
          return onBlur;
      }
  
      /** Sets the onFocus event handler. */
      public void setOnFocus(String onFocus) {
          this.onFocus = onFocus;
      }
  
      /** Returns the onFocus event handler. */
      public String getOnFocus() {
          return onFocus;
      }
  
  // CSS Style Support
  
      /** Sets the style attribute. */
      public void setStyle(String style) {
          this.style = style;
      }
  
      /** Returns the style attribute. */
      public String getStyle() {
          return style;
      }
  
      /** Sets the style class attribute. */
      public void setStyleClass(String styleClass) {
          this.styleClass = styleClass;
      }
  
      /** Returns the style class attribute. */
      public String getStyleClass() {
          return styleClass;
      }
  
      /**
       * Prepares the style attributes for inclusion in the component's HTML tag.
       * @return The prepared String for inclusion in the HTML tag.
       */
      protected String prepareStyles() {
          StringBuffer styles = new StringBuffer();
          if (style != null) {
              styles.append(" style=\"");
              styles.append(style);
              styles.append("\"");
          }
          if (styleClass != null) {
              styles.append(" styleClass=\"");
              styles.append(styleClass);
              styles.append("\"");
          }
          return styles.toString();
      }
  
      /**
       * Prepares the event handlers for inclusion in the component's HTML tag.
       * @return The prepared String for inclusion in the HTML tag.
       */
      protected String prepareEventHandlers() {
          StringBuffer handlers = new StringBuffer();
          prepareMouseEvents(handlers);
          prepareKeyEvents(handlers);
          prepareTextEvents(handlers);
          prepareFocusEvents(handlers);
          return handlers.toString();
      }
  
      /**
       * Prepares the mouse event handlers, appending them to the the given
       * StringBuffer.
       * @param handlers The StringBuffer that output will be appended to.
       */
      private void prepareMouseEvents(StringBuffer handlers) {
          if (onClick != null) {
              handlers.append(" onClick=\"");
              handlers.append(onClick);
              handlers.append("\"");
          }
  
          if (onDblClick != null) {
              handlers.append(" onDblClick=\"");
              handlers.append(onDblClick);
              handlers.append("\"");
          }
  
          if (onMouseOver != null) {
              handlers.append(" onMouseOver=\"");
              handlers.append(onMouseOver);
              handlers.append("\"");
          }
  
          if (onMouseOut != null) {
              handlers.append(" onMouseOut=\"");
              handlers.append(onMouseOut);
              handlers.append("\"");
          }
  
          if (onMouseMove != null) {
              handlers.append(" onMouseMove=\"");
              handlers.append(onMouseMove);
              handlers.append("\"");
          }
  
          if (onMouseDown != null) {
              handlers.append(" onMouseDown=\"");
              handlers.append(onMouseDown);
              handlers.append("\"");
          }
  
          if (onMouseUp != null) {
              handlers.append(" onMouseUp=\"");
              handlers.append(onMouseUp);
              handlers.append("\"");
          }
      }
  
      /**
       * Prepares the keyboard event handlers, appending them to the the given
       * StringBuffer.
       * @param handlers The StringBuffer that output will be appended to.
       */
      private void prepareKeyEvents(StringBuffer handlers) {
  
          if (onKeyDown != null) {
              handlers.append(" onKeyDown=\"");
              handlers.append(onKeyDown);
              handlers.append("\"");
          }
  
          if (onKeyUp != null) {
              handlers.append(" onKeyUp=\"");
              handlers.append(onKeyUp);
              handlers.append("\"");
          }
  
          if (onKeyPress != null) {
              handlers.append(" onKeyPress=\"");
              handlers.append(onKeyPress);
              handlers.append("\"");
          }
      }
  
      /**
       * Prepares the text event handlers, appending them to the the given
       * StringBuffer.
       * @param handlers The StringBuffer that output will be appended to.
       */
      private void prepareTextEvents(StringBuffer handlers) {
  
          if (onSelect != null) {
              handlers.append(" onSelect=\"");
              handlers.append(onSelect);
              handlers.append("\"");
          }
  
          if (onChange != null) {
              handlers.append(" onChange=\"");
              handlers.append(onChange);
              handlers.append("\"");
          }
      }
  
      /**
       * Prepares the focus event handlers, appending them to the the given
       * StringBuffer.
       * @param handlers The StringBuffer that output will be appended to.
       */
      private void prepareFocusEvents(StringBuffer handlers) {
  
          if (onBlur != null) {
              handlers.append(" onBlur=\"");
              handlers.append(onBlur);
              handlers.append("\"");
          }
  
          if (onFocus != null) {
              handlers.append(" onFocus=\"");
              handlers.append(onFocus);
              handlers.append("\"");
          }
      }
  
  
  
  
  }
  
  
  1.1                  jakarta-struts/src/share/org/apache/struts/taglib/ButtonTag.java
  
  Index: ButtonTag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/ButtonTag.java,v 1.1 2000/06/15 01:27:34 craigmcc Exp $
   * $Revision: 1.1 $
   * $Date: 2000/06/15 01:27:34 $
   *
   * ====================================================================
   *
   * 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.struts.taglib;
  
  
  import java.io.IOException;
  import javax.servlet.jsp.JspException;
  import javax.servlet.jsp.PageContext;
  import javax.servlet.jsp.JspWriter;
  import org.apache.struts.util.BeanUtils;
  
  
  /**
   * Renders an HTML BUTTON tag within the Struts framework.
   *
   * @author Don Clasen
   * @version $Revision: 1.1 $ $Date: 2000/06/15 01:27:34 $
   */
  
  public final class ButtonTag extends BaseHandlerTag {
  
  
      // ----------------------------------------------------- Instance Variables
  
      /**
       * The name of the generated button.
       */
      private String name = null;
  
  
      /**
       * The value of the button label.
       */
      private String value = null;
  
  
      // ------------------------------------------------------------- Properties
  
  
      /**
       * Return the component name.
       */
      public String getName() {
          return (name);
      }
  
      /**
       * Set the component name.
       * @param name The component name
       */
      public void setName(String name) {
          this.name = name;
      }
  
  
      /**
       * Return the label value.
       */
      public String getValue() {
          return (value);
      }
  
  
      /**
       * Set the label value.
       * @param value The label value
       */
      public void setValue(String value) {
          this.value = value;
      }
  
      // --------------------------------------------------------- Public Methods
  
      /**
       * Process the start of this tag.
       * @exception JspException if a JSP exception has occurred
       */
      public int doStartTag() throws JspException {
          // Do nothing until doEndTag() is called
          return (EVAL_BODY_TAG);
      }
  
      /**
       * Process the end of this tag.
       * @exception JspException if a JSP exception has occurred
       */
      public int doEndTag() throws JspException {
  
      // Acquire the label value we will be generating
      String label = value;
      if ((label == null) && (bodyContent != null))
          label = bodyContent.getString().trim();
      if ((label == null) || (label.trim().length() < 1))
          label = "Click";
  
      // Generate an HTML element
      StringBuffer results = new StringBuffer();
      results.append("<input type=\"button\"");
      if (name != null) {
          results.append(" name=\"");
          results.append(name);
          results.append("\"");
      }
      results.append(" value=\"");
      results.append(label);
      results.append("\"");
      results.append(prepareEventHandlers());
      results.append(prepareStyles());
      results.append(">");
  
      // Render this element to our writer
      JspWriter writer = pageContext.getOut();
      try {
          writer.print(results.toString());
      }
      catch (IOException e) {
          throw new JspException
          (messages.getMessage("baseFieldTag.io", e.toString()));
      }
  
      return (EVAL_PAGE);
  
      }
  
  
  }