husted      2002/07/07 16:27:57

  Modified:    src/share/org/apache/struts/taglib/html RadioTag.java
  Log:
  Add idName attribute  to RadioTag so that it is easy to use with an iterator.
  
  Revision  Changes    Path
  1.13      +60 -4     
jakarta-struts/src/share/org/apache/struts/taglib/html/RadioTag.java
  
  Index: RadioTag.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/RadioTag.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- RadioTag.java     25 Jun 2002 00:45:41 -0000      1.12
  +++ RadioTag.java     7 Jul 2002 23:27:57 -0000       1.13
  @@ -77,6 +77,7 @@
    * Tag for input fields of type "radio".
    *
    * @author Craig R. McClanahan
  + * @author Ted Husted
    * @version $Revision$ $Date$
    */
   
  @@ -125,6 +126,20 @@
       protected String value = null;
   
   
  +    /**
  +     * Name of the bean (in some scope) that will return the
  +     * value of the radio tag.
  +     * <p>
  +     * If an iterator is used to render a series of radio tags,
  +     * this field may be used to specify the name of the bean
  +     * exposed by the iterator. In this case, the value attribute is
  +     * used as the name of a property on the <code>idName</code> bean
  +     * that returns the value of the radio tag in this iteration.
  +     */
  +    protected String idName = null;
  +
  +
  +
       // ------------------------------------------------------------- Properties
   
   
  @@ -172,6 +187,32 @@
       }
   
   
  +
  +    /**
  +     * Return the idName.
  +     * @since Struts 1.1
  +     */
  +    public String getIdName() {
  +
  +        return (this.idName);
  +
  +    }
  +
  +
  +    /**
  +     * Set the idName.
  +     * @since Struts 1.1
  +     *
  +     * @param value The new idName
  +     */
  +    public void setIdName(String idName) {
  +
  +        this.idName=idName;
  +
  +    }
  +
  +
  +
       // --------------------------------------------------------- Public Methods
   
   
  @@ -190,9 +231,22 @@
               throw new JspException
                   (messages.getMessage("getter.bean", name));
           try {
  +
               current = BeanUtils.getProperty(bean, property);
               if (current == null)
                   current = "";
  +
  +            // @since Struts 1.1
  +            if (idName != null) {
  +                Object idBean = pageContext.findAttribute(idName);
  +                if (idBean == null)
  +                   throw new JspException
  +                    (messages.getMessage("getter.bean", idName));
  +                value = BeanUtils.getProperty(idBean, value);
  +                if (value == null) value = "";
  +            }
  +
  +
               } catch (IllegalAccessException e) {
                   throw new JspException
                       (messages.getMessage("getter.access", property, name));
  @@ -205,6 +259,8 @@
               throw new JspException
                   (messages.getMessage("getter.method", property, name));
           }
  +
  +
   
           // Create an appropriate "input" element based on our parameters
           StringBuffer results = new StringBuffer("<input type=\"radio\"");
  
  
  

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

Reply via email to