You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by hu...@apache.org on 2004/01/08 17:17:33 UTC

cvs commit: jakarta-struts/src/examples/org/apache/struts/webapp/exercise TestBean.java MessageResources_fr.properties MessageResources_de.properties MessageResources.properties HtmlSettersAction.java ApplicationResources_ja.properties

husted      2004/01/08 08:17:33

  Added:       src/examples/org/apache/struts/webapp/exercise TestBean.java
                        MessageResources_fr.properties
                        MessageResources_de.properties
                        MessageResources.properties HtmlSettersAction.java
                        ApplicationResources_ja.properties
  Log:
  Place source code for exercise module under examples.
  
  Revision  Changes    Path
  1.1                  jakarta-struts/src/examples/org/apache/struts/webapp/exercise/TestBean.java
  
  Index: TestBean.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-struts/src/examples/org/apache/struts/webapp/exercise/TestBean.java,v 1.1 2004/01/08 16:17:33 husted Exp $
   * $Revision: 1.1 $
   * $Date: 2004/01/08 16:17:33 $
   *
   * ====================================================================
   *
   * 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 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.webapp.exercise;
  
  
  import java.util.ArrayList;
  import java.util.Collection;
  import java.util.HashMap;
  import java.util.List;
  import java.util.Map;
  import java.util.Vector;
  import javax.servlet.http.HttpServletRequest;
  import org.apache.struts.action.ActionForm;
  import org.apache.struts.action.ActionMapping;
  import org.apache.struts.util.LabelValueBean;
  
  
  /**
   * General purpose test bean for Struts custom tag tests.
   *
   * @author Craig R. McClanahan
   * @author Martin F N Cooper
   * @version $Revision: 1.1 $ $Date: 2004/01/08 16:17:33 $
   */
  
  public class TestBean extends ActionForm {
  
  
      // ------------------------------------------------------------- Properties
  
  
      /**
       * A collection property where the elements of the collection are
       * of type <code>LabelValueBean</code>.
       */
      private Collection beanCollection = null;
  
      public Collection getBeanCollection() {
          if (beanCollection == null) {
              Vector entries = new Vector(10);
  
              entries.add(new LabelValueBean("Label 0", "Value 0"));
              entries.add(new LabelValueBean("Label 1", "Value 1"));
              entries.add(new LabelValueBean("Label 2", "Value 2"));
              entries.add(new LabelValueBean("Label 3", "Value 3"));
              entries.add(new LabelValueBean("Label 4", "Value 4"));
              entries.add(new LabelValueBean("Label 5", "Value 5"));
              entries.add(new LabelValueBean("Label 6", "Value 6"));
              entries.add(new LabelValueBean("Label 7", "Value 7"));
              entries.add(new LabelValueBean("Label 8", "Value 8"));
              entries.add(new LabelValueBean("Label 9", "Value 9"));
  
              beanCollection = entries;
          }
  
          return (beanCollection);
      }
  
      public void setBeanCollection(Collection beanCollection) {
          this.beanCollection = beanCollection;
      }
  
  
      /**
       * A multiple-String SELECT element using a bean collection.
       */
      private String[] beanCollectionSelect = { "Value 1", "Value 3",
                                                "Value 5" };
  
      public String[] getBeanCollectionSelect() {
          return (this.beanCollectionSelect);
      }
  
      public void setBeanCollectionSelect(String beanCollectionSelect[]) {
          this.beanCollectionSelect = beanCollectionSelect;
      }
  
  
      /**
       * A boolean property whose initial value is true.
       */
      private boolean booleanProperty = true;
  
      public boolean getBooleanProperty() {
          return (booleanProperty);
      }
  
      public void setBooleanProperty(boolean booleanProperty) {
          this.booleanProperty = booleanProperty;
      }
  
  
      /**
       * 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;
  
      public double getDoubleProperty() {
          return (this.doubleProperty);
      }
  
      public void setDoubleProperty(double doubleProperty) {
          this.doubleProperty = doubleProperty;
      }
  
  
      /**
       * A boolean property whose initial value is false
       */
      private boolean falseProperty = false;
  
      public boolean getFalseProperty() {
          return (falseProperty);
      }
  
      public void setFalseProperty(boolean falseProperty) {
          this.falseProperty = falseProperty;
      }
  
  
      /**
       * A float property.
       */
      private float floatProperty = (float) 123.0;
  
      public float getFloatProperty() {
          return (this.floatProperty);
      }
  
      public void setFloatProperty(float floatProperty) {
          this.floatProperty = floatProperty;
      }
  
  
      /**
       * Integer arrays that are accessed as an array as well as indexed.
       */
      private int intArray[] = { 0, 10, 20, 30, 40 };
  
      public int[] getIntArray() {
          return (this.intArray);
      }
  
      public void setIntArray(int intArray[]) {
          this.intArray = intArray;
      }
  
      private int intIndexed[] = { 0, 10, 20, 30, 40 };
  
      public int getIntIndexed(int index) {
          return (intIndexed[index]);
      }
  
      public void setIntIndexed(int index, int value) {
          intIndexed[index] = value;
      }
  
  
      private int intMultibox[] = new int[0];
  
      public int[] getIntMultibox() {
          return (this.intMultibox);
      }
  
      public void setIntMultibox(int intMultibox[]) {
          this.intMultibox = intMultibox;
      }
  
      /**
       * An integer property.
       */
      private int intProperty = 123;
  
      public int getIntProperty() {
          return (this.intProperty);
      }
  
      public void setIntProperty(int intProperty) {
          this.intProperty = intProperty;
      }
  
  
      /**
       * A long property.
       */
      private long longProperty = 321;
  
      public long getLongProperty() {
          return (this.longProperty);
      }
  
      public void setLongProperty(long longProperty) {
          this.longProperty = longProperty;
      }
  
  
      /**
       * A multiple-String SELECT element.
       */
      private String[] multipleSelect = { "Multiple 3", "Multiple 5",
                                          "Multiple 7" };
  
      public String[] getMultipleSelect() {
          return (this.multipleSelect);
      }
  
      public void setMultipleSelect(String multipleSelect[]) {
          this.multipleSelect = multipleSelect;
      }
  
  
      /**
       * A nested reference to another test bean (populated as needed).
       */
      private TestBean nested = null;
  
      public TestBean getNested() {
          if (nested == null)
              nested = new TestBean();
          return (nested);
      }
  
  
      /**
       * A String property with an initial value of null.
       */
      private String nullProperty = null;
  
      public String getNullProperty() {
          return (this.nullProperty);
      }
  
      public void setNullProperty(String nullProperty) {
          this.nullProperty = nullProperty;
      }
  
  
      /**
       * A short property.
       */
      private short shortProperty = (short) 987;
  
      public short getShortProperty() {
          return (this.shortProperty);
      }
  
      public void setShortProperty(short shortProperty) {
          this.shortProperty = shortProperty;
      }
  
  
      /**
       * A single-String value for a SELECT element.
       */
      private String singleSelect = "Single 5";
  
      public String getSingleSelect() {
          return (this.singleSelect);
      }
  
      public void setSingleSelect(String singleSelect) {
          this.singleSelect = singleSelect;
      }
  
  
      /**
       * String arrays that are accessed as an array as well as indexed.
       */
      private String stringArray[] =
      { "String 0", "String 1", "String 2", "String 3", "String 4" };
  
      public String[] getStringArray() {
          return (this.stringArray);
      }
  
      public void setStringArray(String stringArray[]) {
          this.stringArray = stringArray;
      }
  
      private String stringIndexed[] =
      { "String 0", "String 1", "String 2", "String 3", "String 4" };
  
      public String getStringIndexed(int index) {
          return (stringIndexed[index]);
      }
  
      public void setStringIndexed(int index, String value) {
          stringIndexed[index] = value;
      }
  
  
      private String stringMultibox[] = new String[0];
  
      public String[] getStringMultibox() {
          return (this.stringMultibox);
      }
  
      public void setStringMultibox(String stringMultibox[]) {
          this.stringMultibox = stringMultibox;
      }
  
      /**
       * A String property.
       */
      private String stringProperty = "This is a string";
  
      public String getStringProperty() {
          return (this.stringProperty);
      }
  
      public void setStringProperty(String stringProperty) {
          this.stringProperty = stringProperty;
      }
  
      /**
       * An empty String property.
       */
      private String emptyStringProperty = "";
  
      public String getEmptyStringProperty() {
          return (this.emptyStringProperty);
      }
  
      public void setEmptyStringProperty(String emptyStringProperty) {
          this.emptyStringProperty = emptyStringProperty;
      }
  
  
      /**
       * A single-String value for a SELECT element based on resource strings.
       */
      private String resourcesSelect = "Resources 2";
  
      public String getResourcesSelect() {
          return (this.resourcesSelect);
      }
  
      public void setResourcesSelect(String resourcesSelect) {
          this.resourcesSelect = resourcesSelect;
      }
  
  
      /**
       * A property that allows a null value but is still used in a SELECT.
       */
      private String withNulls = null;
  
      public String getWithNulls() {
          return (this.withNulls);
      }
  
      public void setWithNulls(String withNulls) {
          this.withNulls = withNulls;
      }
  
  
      /**
       * A List property.
       */
      private List listProperty = null;
  
      public List getListProperty() {
          if (listProperty == null) {
              listProperty = new ArrayList();
              listProperty.add("dummy");
          }
          return listProperty;
      }
  
      public void setListProperty(List listProperty) {
          this.listProperty = listProperty;
      }
  
      /**
       * An empty List property.
       */
      private List emptyListProperty = null;
  
      public List getEmptyListProperty() {
          if (emptyListProperty == null) {
              emptyListProperty = new ArrayList();
          }
          return emptyListProperty;
      }
  
      public void setEmptyListProperty(List emptyListProperty) {
          this.emptyListProperty = emptyListProperty;
      }
  
  
      /**
       * A Map property.
       */
      private Map mapProperty = null;
  
      public Map getMapProperty() {
          if (mapProperty == null) {
              mapProperty = new HashMap();
              mapProperty.put("dummy", "dummy");
          }
          return mapProperty;
      }
  
      public void setMapProperty(Map mapProperty) {
          this.mapProperty = mapProperty;
      }
  
      /**
       * An empty Map property.
       */
      private Map emptyMapProperty = null;
  
      public Map getEmptyMapProperty() {
          if (emptyMapProperty == null) {
              emptyMapProperty = new HashMap();
          }
          return emptyMapProperty;
      }
  
      public void setEmptyMapProperty(Map emptyMapProperty) {
          this.emptyMapProperty = emptyMapProperty;
      }
  
  
      // --------------------------------------------------------- Public Methods
  
  
      /**
       * Reset the properties that will be received as input.
       */
      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];
          if (nested != null)
              nested.reset(mapping, request);
  
      }
  
  
  }
  
  
  
  1.1                  jakarta-struts/src/examples/org/apache/struts/webapp/exercise/MessageResources_fr.properties
  
  Index: MessageResources_fr.properties
  ===================================================================
  #
  # Resources for testing <bean:write> tag.
  #
  double.pattern=#\u00a0000,00
  locale.en=
  locale.fr=(*)
  
  
  
  1.1                  jakarta-struts/src/examples/org/apache/struts/webapp/exercise/MessageResources_de.properties
  
  Index: MessageResources_de.properties
  ===================================================================
  #
  # Resources for testing <bean:write> tag.
  #
  double.pattern=#.000,00
  locale.en=
  locale.de=(*)
  
  
  
  1.1                  jakarta-struts/src/examples/org/apache/struts/webapp/exercise/MessageResources.properties
  
  Index: MessageResources.properties
  ===================================================================
  #
  # Resources for testing <html:errors> tag.
  #
  
  errors.header=<table>
  errors.footer=</table>
  errors.prefix=<tr><td>
  errors.suffix=</td></tr>
  
  property1error1=Property 1, Error 1
  property2error1=Property 2, Error 1
  property2error2=Property 2, Error 2
  property2error3=Property 2, Error 3
  property3error1=Property 3, Error 1
  property3error2=Property 3, Error 2
  globalError=Global Error
  
  #
  # Resources for testing <html:messages> tag.
  #
  
  messages.header=<table>
  messages.footer=</table>
  
  property1message1=Property 1, Message 1
  property2message1=Property 2, Message 1
  property2message2=Property 2, Message 2
  property2message3=Property 2, Message 3
  property3message1=Property 3, Message 1
  property3message2=Property 3, Message 2
  globalMessage=Global Message
  
  #
  # Resources for testing <html:option>.
  #
  
  resources0=Resources 0
  resources1=Resources 1
  resources2=Resources 2
  
  
  #
  # Resources for testing <bean:write> tag.
  #
  
  double.pattern=#,000.00
  date.pattern=EEE, MMM d, ''yy
  locale.de=
  locale.en=(*)
  locale.fr=
  
  
  
  1.1                  jakarta-struts/src/examples/org/apache/struts/webapp/exercise/HtmlSettersAction.java
  
  Index: HtmlSettersAction.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-struts/src/examples/org/apache/struts/webapp/exercise/HtmlSettersAction.java,v 1.1 2004/01/08 16:17:33 husted Exp $
   * $Revision: 1.1 $
   * $Date: 2004/01/08 16:17:33 $
   *
   * ====================================================================
   *
   * 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 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.webapp.exercise;
  
  
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  import org.apache.struts.action.Action;
  import org.apache.struts.action.ActionForm;
  import org.apache.struts.action.ActionForward;
  import org.apache.struts.action.ActionMapping;
  
  
  /**
   * Do-nothing action that accepts the changes made automatically in our form
   * bean, and then returns control to the input form (if "Save" was pressed)
   * or the main menu (if "Cancel" was pressed).
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2004/01/08 16:17:33 $
   */
  
  public class HtmlSettersAction extends Action {
  
  
      /**
       * Forward to the input form if "Save" was pressed or the main menu
       * if "Cancel" was pressed.
       *
       * @param mapping The ActionMapping used to select this instance
       * @param form The optional ActionForm bean for this request
       * @param request The servlet request we are processing
       * @param response The servlet response we are creating
       *
       * @exception Exception if business logic throws an exception
       */
      public ActionForward execute(ActionMapping mapping,
                                   ActionForm form,
                                   HttpServletRequest request,
                                   HttpServletResponse response)
          throws Exception {
  
          if (isCancelled(request))
              return (mapping.findForward("index"));
          else
              return (mapping.findForward("input"));
  
      }
  
  
  }
  
  
  
  1.1                  jakarta-struts/src/examples/org/apache/struts/webapp/exercise/ApplicationResources_ja.properties
  
  Index: ApplicationResources_ja.properties
  ===================================================================
  #
  # Resources for testing <html:errors> tag.
  #
  
  errors.header=<table>
  errors.footer=</table>
  errors.prefix=<tr><td>
  errors.suffix=</td></tr>
  
  property1error1=\u30d7\u30ed\u30d1\u30c6\u30a3 1, \u30a8\u30e9\u30fc 1
  property2error1=\u30d7\u30ed\u30d1\u30c6\u30a3 2, \u30a8\u30e9\u30fc 1
  property2error2=\u30d7\u30ed\u30d1\u30c6\u30a3 2, \u30a8\u30e9\u30fc 2
  property2error3=\u30d7\u30ed\u30d1\u30c6\u30a3 2, \u30a8\u30e9\u30fc 3
  property3error1=\u30d7\u30ed\u30d1\u30c6\u30a3 3, \u30a8\u30e9\u30fc 1
  property3error2=\u30d7\u30ed\u30d1\u30c6\u30a3 3, \u30a8\u30e9\u30fc 2
  globalError=\u30b0\u30ed\u30fc\u30d0\u30eb\u30a8\u30e9\u30fc
  
  #
  # Resources for testing <html:messages> tag.
  #
  
  messages.header=<table>
  messages.footer=</table>
  
  property1message1=\u30d7\u30ed\u30d1\u30c6\u30a3 1, \u30e1\u30c3\u30bb\u30fc\u30b8 1
  property2message1=\u30d7\u30ed\u30d1\u30c6\u30a3 2, \u30e1\u30c3\u30bb\u30fc\u30b8 1
  property2message2=\u30d7\u30ed\u30d1\u30c6\u30a3 2, \u30e1\u30c3\u30bb\u30fc\u30b8 2
  property2message3=\u30d7\u30ed\u30d1\u30c6\u30a3 2, \u30e1\u30c3\u30bb\u30fc\u30b8 3
  property3message1=\u30d7\u30ed\u30d1\u30c6\u30a3 3, \u30e1\u30c3\u30bb\u30fc\u30b8 1
  property3message2=\u30d7\u30ed\u30d1\u30c6\u30a3 3, \u30e1\u30c3\u30bb\u30fc\u30b8 2
  globalMessage=\u30b0\u30ed\u30fc\u30d0\u30eb\u30e1\u30c3\u30bb\u30fc\u30b8
  
  #
  # Resources for testing <html:option>.
  #
  
  resources0=\u30ea\u30bd\u30fc\u30b9 0
  resources1=\u30ea\u30bd\u30fc\u30b9 1
  resources2=\u30ea\u30bd\u30fc\u30b9 2
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org