martinc     01/10/14 22:50:11

  Modified:    src/exercise-taglib/org/apache/struts/webapp/exercise
                        TestBean.java
               web/exercise-taglib html-select.jsp
  Added:       src/exercise-taglib/org/apache/struts/webapp/exercise
                        OptionBean.java
  Log:
  Added test case for <html:select> using <html:options> based on a collection
  saved in the page context.
  
  Revision  Changes    Path
  1.4       +20 -4     
jakarta-struts/src/exercise-taglib/org/apache/struts/webapp/exercise/TestBean.java
  
  Index: TestBean.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-struts/src/exercise-taglib/org/apache/struts/webapp/exercise/TestBean.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TestBean.java     2001/07/08 04:15:12     1.3
  +++ TestBean.java     2001/10/15 05:50:10     1.4
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-struts/src/exercise-taglib/org/apache/struts/webapp/exercise/TestBean.java,v
 1.3 2001/07/08 04:15:12 martinc Exp $
  - * $Revision: 1.3 $
  - * $Date: 2001/07/08 04:15:12 $
  + * $Header: 
/home/cvs/jakarta-struts/src/exercise-taglib/org/apache/struts/webapp/exercise/TestBean.java,v
 1.4 2001/10/15 05:50:10 martinc Exp $
  + * $Revision: 1.4 $
  + * $Date: 2001/10/15 05:50:10 $
    *
    * ====================================================================
    *
  @@ -72,7 +72,7 @@
    * General purpose test bean for Struts custom tag tests.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.3 $ $Date: 2001/07/08 04:15:12 $
  + * @version $Revision: 1.4 $ $Date: 2001/10/15 05:50:10 $
    */
   
   public class TestBean extends ActionForm {
  @@ -96,6 +96,21 @@
   
   
       /**
  +     * A multiple-String SELECT element using a collection.
  +     */
  +    private String[] collectionSelect = { "Value 2", "Value 4",
  +                                          "Value 6" };
  +
  +    public String[] getCollectionSelect() {
  +        return (this.collectionSelect);
  +    }
  +
  +    public void setCollectionSelect(String collectionSelect[]) {
  +        this.collectionSelect = collectionSelect;
  +    }
  +
  +
  +    /**
        * A double property.
        */
       private double doubleProperty = 321.0;
  @@ -340,6 +355,7 @@
       public void reset(ActionMapping mapping, HttpServletRequest request) {
   
           booleanProperty = false;
  +        collectionSelect = new String[0];
           intMultibox = new int[0];
           multipleSelect = new String[0];
           stringMultibox = new String[0];
  
  
  
  1.1                  
jakarta-struts/src/exercise-taglib/org/apache/struts/webapp/exercise/OptionBean.java
  
  Index: OptionBean.java
  ===================================================================
  /*
   * $Header: 
/home/cvs/jakarta-struts/src/exercise-taglib/org/apache/struts/webapp/exercise/OptionBean.java,v
 1.1 2001/10/15 05:50:10 martinc Exp $
   * $Revision: 1.1 $
   * $Date: 2001/10/15 05:50:10 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2001 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", "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.struts.webapp.exercise;
  
  
  /**
   * A simple bean for use in testing the <code>&lt;html:options&gt;</code> tag
   * in conjunction with the <code>collection</code> attribute.
   *
   * @author  Martin F N Cooper
   * @version $Revision: 1.1 $ $Date: 2001/10/15 05:50:10 $
   */
  
  public class OptionBean {
  
  
      // ----------------------------------------------------------- Constructors
  
  
      /**
       * Construct an instance with the supplied property values.
       */
      public OptionBean(String label, String value) {
          this.label = label;
          this.value = value;
      }
  
  
      // ------------------------------------------------------------- Properties
  
  
      /**
       * The property which supplies the option label visible to the end user.
       */
      private String label;
  
      public String getLabel() {
          return this.label;
      }
  
      public void setLabel(String label) {
          this.label = label;
      }
  
  
      /**
       * The property which supplies the value returned to the server.
       */
      private String value;
  
      public String getValue() {
          return this.value;
      }
  
      public void setValue(String value) {
          this.value = value;
      }
  
  
  }
  
  
  
  1.2       +23 -1     jakarta-struts/web/exercise-taglib/html-select.jsp
  
  Index: html-select.jsp
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/web/exercise-taglib/html-select.jsp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- html-select.jsp   2001/03/07 04:50:54     1.1
  +++ html-select.jsp   2001/10/15 05:50:11     1.2
  @@ -1,4 +1,4 @@
  -<%@ page language="java"%>
  +<%@ page language="java" import="java.util.*, 
org.apache.struts.webapp.exercise.*;"%>
   <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
   <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
   <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
  @@ -10,6 +10,19 @@
      { "Multiple 0", "Multiple 1", "Multiple 2", "Multiple 3", "Multiple 4",
        "Multiple 5", "Multiple 6", "Multiple 7", "Multiple 8", "Multiple 9" };
     pageContext.setAttribute("multipleValues", multipleValues);
  +
  +  Vector options = new Vector();
  +  options.add(new OptionBean("Label 0", "Value 0"));
  +  options.add(new OptionBean("Label 1", "Value 1"));
  +  options.add(new OptionBean("Label 2", "Value 2"));
  +  options.add(new OptionBean("Label 3", "Value 3"));
  +  options.add(new OptionBean("Label 4", "Value 4"));
  +  options.add(new OptionBean("Label 5", "Value 5"));
  +  options.add(new OptionBean("Label 6", "Value 6"));
  +  options.add(new OptionBean("Label 7", "Value 7"));
  +  options.add(new OptionBean("Label 8", "Value 8"));
  +  options.add(new OptionBean("Label 9", "Value 9"));
  +  pageContext.setAttribute("options", options);
   %>
   </head>
   <body bgcolor="white">
  @@ -48,6 +61,15 @@
       <td align="left">
         <html:select property="multipleSelect" size="10" multiple="true">
           <html:options name="multipleValues" labelName="multipleValues"/>
  +      </html:select>
  +    </td>
  +  </tr>
  +
  +  <tr>
  +    <th align="right">Multiple Select From A Collection:</th>
  +    <td align="left">
  +      <html:select property="collectionSelect" size="10" multiple="true">
  +        <html:options collection="options" property="value" labelProperty="label"/>
         </html:select>
       </td>
     </tr>
  
  
  


Reply via email to