rleland 01/03/06 21:35:28 Added: src/exercise-taglib/org/apache/struts/exercise TestBean.java HtmlSettersAction.java Log: Humble myself and learn that '-' is not allowed in package names, so remove 'exercise-taglib' and call it 'exercise' Revision Changes Path 1.1 jakarta-struts/src/exercise-taglib/org/apache/struts/exercise/TestBean.java Index: TestBean.java =================================================================== /* * $Header: /home/cvs/jakarta-struts/src/exercise-taglib/org/apache/struts/exercise/TestBean.java,v 1.1 2001/03/07 05:35:28 rleland Exp $ * $Revision: 1.1 $ * $Date: 2001/03/07 05:35:28 $ * * ==================================================================== * * 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.exercise; import javax.servlet.http.HttpServletRequest; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionMapping; /** * General purpose test bean for Struts custom tag tests. * * @author Craig R. McClanahan * @version $Revision: 1.1 $ $Date: 2001/03/07 05:35:28 $ */ public class TestBean extends ActionForm { // ------------------------------------------------------------- Properties /** * A boolean property. */ private boolean booleanProperty = true; public boolean getBooleanProperty() { return (booleanProperty); } public void setBooleanProperty(boolean booleanProperty) { this.booleanProperty = booleanProperty; } /** * A double property. */ private double doubleProperty = 321.0; public double getDoubleProperty() { return (this.doubleProperty); } public void setDoubleProperty(double doubleProperty) { this.doubleProperty = doubleProperty; } /** * 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; } // --------------------------------------------------------- Public Methods /** * Reset the properties that will be received as input. */ public void reset(ActionMapping mapping, HttpServletRequest request) { booleanProperty = false; intMultibox = new int[0]; multipleSelect = new String[0]; stringMultibox = new String[0]; if (nested != null) nested.reset(mapping, request); } } 1.1 jakarta-struts/src/exercise-taglib/org/apache/struts/exercise/HtmlSettersAction.java Index: HtmlSettersAction.java =================================================================== /* * $Header: /home/cvs/jakarta-struts/src/exercise-taglib/org/apache/struts/exercise/HtmlSettersAction.java,v 1.1 2001/03/07 05:35:28 rleland Exp $ * $Revision: 1.1 $ * $Date: 2001/03/07 05:35:28 $ * * ==================================================================== * * 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.exercise; import java.io.IOException; import javax.servlet.ServletException; 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: 2001/03/07 05:35:28 $ */ 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 actionForm The optional ActionForm bean for this request * @param request The servlet request we are processing * @param response The servlet response we are creating * * @exception IOException if an input/output error occurs * @exception ServletException if a servlet exception occurs */ public ActionForward perform(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { if (isCancelled(request)) return (mapping.findForward("index")); else return (mapping.findForward("input")); } }