You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-dev@jakarta.apache.org by sh...@apache.org on 2001/05/12 03:42:05 UTC

cvs commit: jakarta-taglibs/input/src/org/apache/taglibs/input Checkbox.java

shawn       01/05/11 18:42:05

  Modified:    input/src/org/apache/taglibs/input Checkbox.java
  Log:
  Improved lifecycle management by ensuring accessors have straightforward
  role.  Only the <input:checkbox> tag has been modified.
  
  Revision  Changes    Path
  1.2       +13 -18    jakarta-taglibs/input/src/org/apache/taglibs/input/Checkbox.java
  
  Index: Checkbox.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/input/src/org/apache/taglibs/input/Checkbox.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Checkbox.java	2000/08/25 03:26:19	1.1
  +++ Checkbox.java	2001/05/12 01:42:05	1.2
  @@ -74,7 +74,8 @@
   
       private String name;		// name of the checkbox group
       private String value;		// value of this particular button
  -    private Vector dVals;		// default value(s) if none are found
  +    private String dVal;		// our single default value
  +    private String[] dValArray;		// our multiple default values
       private Map attributes;		// attributes of the <input> element
   
       public void setName(String x) {
  @@ -89,27 +90,12 @@
   	attributes = x;
       }
   
  -    /**
  -     *  Acts more as an additive function than a normal accessor.
  -     *  (I'd call this addDefault if I could.)
  -     */
       public void setDefault(String x) {
  -	if (dVals == null)
  -	    dVals = new Vector();
  -	if (x != null)
  -	    dVals.add(x);
  +	dVal = x;
       }
   
  -    /**
  -     *  Acts more as an additive function than a normal accessor.
  -     *  (I'd call this addDefaults if I could.)
  -     */
       public void setDefaults(String[] x) {
  -	if (dVals == null)
  -	    dVals = new Vector();
  -	if (x != null)
  -	    for (int i = 0; i < x.length; i++)
  -		dVals.add(x[i]);
  +	dValArray = x;
       }
   
       public int doStartTag() throws JspException {
  @@ -125,6 +111,15 @@
   	    // get what we need from the page
   	    ServletRequest req = pageContext.getRequest();
   	    JspWriter out = pageContext.getOut();
  +
  +	    // construct a vector of default values
  +	    Vector dVals = new Vector();
  +	    if (dVal != null)
  +		dVals.add(dVal);
  +	    if (dValArray != null)
  +		for (int i = 0; i < dValArray.length; i++)
  +		    if (dValArray[i] != null)
  +			dVals.add(dValArray[i]);
   
   	    // start building up the tag
   	    out.println();