dmkarr 2002/11/03 16:26:48 Modified: contrib/struts-el/src/exercise-taglib/org/apache/struts/webapp/exercise HtmlSettersAction.java TestBean.java contrib/struts-el/web/exercise-taglib html-button.jsp index.jsp contrib/struts-el/web/exercise-taglib/WEB-INF struts-config.xml Added: contrib/struts-el/src/exercise-taglib/org/apache/struts/webapp/exercise Coord.java contrib/struts-el/web/exercise-taglib html-indexed.jsp T1.gif T2.gif Log: Added new struts-el exercise page to test the "indexed" feature of "logic:iterate" and of "text" and "image" (mostly to prove to myself that ImageTag was broken in this respect). Revision Changes Path 1.2 +114 -111 jakarta-struts/contrib/struts-el/src/exercise-taglib/org/apache/struts/webapp/exercise/HtmlSettersAction.java Index: HtmlSettersAction.java =================================================================== RCS file: /home/cvs/jakarta-struts/contrib/struts-el/src/exercise-taglib/org/apache/struts/webapp/exercise/HtmlSettersAction.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- HtmlSettersAction.java 26 Sep 2002 04:54:39 -0000 1.1 +++ HtmlSettersAction.java 4 Nov 2002 00:26:48 -0000 1.2 @@ -1,111 +1,114 @@ -/* - * $Header$ - * $Revision$ - * $Date$ - * - * ==================================================================== - * - * 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; - - -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$ $Date$ - */ - -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 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")); - - } - - -} +/* + * $Header$ + * $Revision$ + * $Date$ + * + * ==================================================================== + * + * 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; + + +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; +import java.util.Map; +import java.util.Set; +import java.util.Iterator; + + +/** + * 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$ $Date$ + */ + +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 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.2 +40 -4 jakarta-struts/contrib/struts-el/src/exercise-taglib/org/apache/struts/webapp/exercise/TestBean.java Index: TestBean.java =================================================================== RCS file: /home/cvs/jakarta-struts/contrib/struts-el/src/exercise-taglib/org/apache/struts/webapp/exercise/TestBean.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- TestBean.java 26 Sep 2002 04:54:39 -0000 1.1 +++ TestBean.java 4 Nov 2002 00:26:48 -0000 1.2 @@ -359,7 +359,14 @@ stringIndexed[index] = value; } + private String indexedStrings[] = + { "alpha", "beta", "gamma", "delta", "epsilon" }; + public String[] getIndexedStrings() + { + return (indexedStrings); + } + private String stringMultibox[] = new String[0]; public String[] getStringMultibox() { @@ -396,7 +403,36 @@ this.emptyStringProperty = emptyStringProperty; } + /** + * A list of coordinate objects. + */ + private Coord[] coords = + { new Coord(0, 0), new Coord(0, 1), new Coord(1, 1), new Coord(2, 0), + new Coord(2, 1) + }; + + public Coord[] getCoords() { return (coords); } + + public Coord getCoord(int index) { return (coords[index]); } + + public void setCoord(int index, Coord coord) { coords[index] = coord; } + + /** + * A list of images. + */ + public String images[] = {"T1.gif", "T2.gif"}; + + public String[] getImages() { return (images); } + + private Coord[] imageCoords = { new Coord(0, 0), new Coord(0, 0) }; + + public Coord[] getImageCoords() { return (imageCoords); } + + public Coord getImageCoord(int index) { return (imageCoords[index]); } + public void setImageCoord(int index, Coord coord) + { imageCoords[index] = coord; } + /** * A property that allows a null value but is still used in a SELECT. */ 1.1 jakarta-struts/contrib/struts-el/src/exercise-taglib/org/apache/struts/webapp/exercise/Coord.java Index: Coord.java =================================================================== /* * $Header: /home/cvs/jakarta-struts/contrib/struts-el/src/exercise-taglib/org/apache/struts/webapp/exercise/Coord.java,v 1.1 2002/11/04 00:26:48 dmkarr Exp $ * $Revision: 1.1 $ * $Date: 2002/11/04 00:26:48 $ * * ==================================================================== * * 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; /** * Simple bean to use for testing indexed tags. */ public class Coord implements java.io.Serializable { private int x; private int y; public Coord() {} public Coord(int x, int y) { this.x = x; this.y = y; } public int getX() { return (x); } public int getY() { return (y); } public void setX(int x) { this.x = x; } public void setY(int y) { this.y = y; } public String toString() { return ("Coord[" + "x=" + x + ";y=" + y + "]"); } } 1.3 +1 -1 jakarta-struts/contrib/struts-el/web/exercise-taglib/html-button.jsp Index: html-button.jsp =================================================================== RCS file: /home/cvs/jakarta-struts/contrib/struts-el/web/exercise-taglib/html-button.jsp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- html-button.jsp 15 Oct 2002 03:12:41 -0000 1.2 +++ html-button.jsp 4 Nov 2002 00:26:48 -0000 1.3 @@ -29,7 +29,7 @@ <tr> <td> <logic-el:iterate collection="${pageScope}" id="item"> - <html-el:button property="stringProperty" indexed="${!empty pageScope}"/> + <html-el:button property="stringIndexed" indexed="${!empty pageScope}"/> </logic-el:iterate> </td> </tr> 1.7 +1 -0 jakarta-struts/contrib/struts-el/web/exercise-taglib/index.jsp Index: index.jsp =================================================================== RCS file: /home/cvs/jakarta-struts/contrib/struts-el/web/exercise-taglib/index.jsp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- index.jsp 1 Nov 2002 04:54:47 -0000 1.6 +++ index.jsp 4 Nov 2002 00:26:48 -0000 1.7 @@ -29,6 +29,7 @@ <li><a href="html-input.jsp"><html:input></a>[<a href="showSource.jsp?path=/html-input.jsp">Source</a>]</li> <li><a href="html-select.jsp"><html:select></a>[<a href="showSource.jsp?path=/html-select.jsp">Source</a>]</li> <li><a href="html-setters.jsp">Scalar Setters</a>[<a href="showSource.jsp?path=/html-setters.jsp">Source</a>]</li> +<li><a href="html-indexed.jsp">Indexed Tags</a>[<a href="showSource.jsp?path=/html-indexed.jsp">Source</a>]</li> </ul> <h3>LOGIC Tags</h3> 1.1 jakarta-struts/contrib/struts-el/web/exercise-taglib/html-indexed.jsp Index: html-indexed.jsp =================================================================== <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <%@ page language="java"%> <%@ taglib uri="/WEB-INF/struts-bean-el.tld" prefix="bean-el" %> <%@ taglib uri="/WEB-INF/struts-html-el.tld" prefix="html-el" %> <%@ taglib uri="/WEB-INF/struts-logic-el.tld" prefix="logic-el" %> <%@ taglib uri="/WEB-INF/c.tld" prefix="c" %> <html-el:html> <head> <title>Test indexed HTML tags</title> </head> <body bgcolor="white"> <div align="center"> <h1>Test indexed HTML tags</h1> </div> <html-el:form action="html-indexed.do"> <table> <logic-el:iterate collection="${testbean.coords}" id="coord" indexId="ctr"> <tr> <td> X:<html-el:text name="coord" property="x" indexed="true"/> </td> <td> Y:<html-el:text name="coord" property="y" indexed="true"/> </td> </tr> </logic-el:iterate> <tr> <td> <html-el:submit property="submitValue"> Submit Changes </html-el:submit> </td> </tr> </table> ( <logic-el:iterate collection="${testbean.coords}" id="coord" indexId="ctr"> [<c:out value="${coord.x}"/>,<c:out value="${coord.y}"/>] </logic-el:iterate> ) <table> <tr> <logic-el:iterate collection="${testbean.images}" id="image" indexId="ctr"> <td> <html-el:image src="${image}" property="imageCoords" indexed="true"/> </td> </logic-el:iterate> </tr> <tr> <logic-el:iterate collection="${testbean.imageCoords}" id="coord" indexId="ctr"> <td> (<c:out value="${coord.x}"/>,<c:out value="${coord.y}"/>) </td> </logic-el:iterate> </tr> </table> </html-el:form> </body> </html-el:html> 1.1 jakarta-struts/contrib/struts-el/web/exercise-taglib/T1.gif <<Binary file>> 1.1 jakarta-struts/contrib/struts-el/web/exercise-taglib/T2.gif <<Binary file>> 1.5 +7 -0 jakarta-struts/contrib/struts-el/web/exercise-taglib/WEB-INF/struts-config.xml Index: struts-config.xml =================================================================== RCS file: /home/cvs/jakarta-struts/contrib/struts-el/web/exercise-taglib/WEB-INF/struts-config.xml,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- struts-config.xml 1 Nov 2002 04:54:47 -0000 1.4 +++ struts-config.xml 4 Nov 2002 00:26:48 -0000 1.5 @@ -97,6 +97,13 @@ validate="false"> <forward name="success" path="/bean-dyna.jsp"/> </action> + <action path="/html-indexed" + type="org.apache.struts.webapp.exercise.HtmlSettersAction" + name="testbean" + scope="session" + validate="false"> + <forward name="input" path="/html-indexed.jsp"/> + </action> </action-mappings> <message-resources
-- To unsubscribe, e-mail: <mailto:struts-dev-unsubscribe@;jakarta.apache.org> For additional commands, e-mail: <mailto:struts-dev-help@;jakarta.apache.org>