struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From craig...@apache.org
Subject cvs commit: jakarta-struts/web/test/WEB-INF struts-config.xml web.xml
Date Mon, 08 Jan 2001 00:17:44 GMT
craigmcc    01/01/07 16:17:44

  Modified:    src/share/org/apache/struts/util RequestUtils.java
               src/test/org/apache/struts/test TestBean.java
               web/test index.jsp
               web/test/WEB-INF web.xml
  Added:       src/test/org/apache/struts/test HtmlSettersAction.java
               web/test html-setters.jsp
               web/test/WEB-INF struts-config.xml
  Log:
  Add a basic test for the property setter methods, to be used in debugging
  and validating their functionality.  (Currently fails with class cast
  exception on doubleProperty).
  
  Revision  Changes    Path
  1.3       +9 -6      jakarta-struts/src/share/org/apache/struts/util/RequestUtils.java
  
  Index: RequestUtils.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/util/RequestUtils.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- RequestUtils.java	2001/01/07 22:39:08	1.2
  +++ RequestUtils.java	2001/01/08 00:17:43	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/util/RequestUtils.java,v
1.2 2001/01/07 22:39:08 craigmcc Exp $
  - * $Revision: 1.2 $
  - * $Date: 2001/01/07 22:39:08 $
  + * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/util/RequestUtils.java,v
1.3 2001/01/08 00:17:43 craigmcc Exp $
  + * $Revision: 1.3 $
  + * $Date: 2001/01/08 00:17:43 $
    *
    * ====================================================================
    *
  @@ -66,7 +66,10 @@
   import java.net.MalformedURLException;
   import java.net.URL;
   import java.util.Enumeration;
  +import java.util.HashMap;
   import java.util.Hashtable;
  +import java.util.Iterator;
  +import java.util.Map;
   import javax.servlet.ServletException;
   import javax.servlet.http.HttpServletRequest;
   import javax.servlet.jsp.PageContext;
  @@ -83,7 +86,7 @@
    * in the Struts controller framework.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.2 $ $Date: 2001/01/07 22:39:08 $
  + * @version $Revision: 1.3 $ $Date: 2001/01/08 00:17:43 $
    */
   
   public class RequestUtils {
  @@ -201,8 +204,8 @@
           throws ServletException {
   
           // Build a list of relevant request parameters from this request
  -        Hashtable properties = new Hashtable();
  -        //Enumeration of parameter names
  +        HashMap properties = new HashMap();
  +        // Iterator of parameter names
           Enumeration names = null;
           //Hashtable for multipart values
           Hashtable multipartElements = null;
  
  
  
  1.3       +25 -5     jakarta-struts/src/test/org/apache/struts/test/TestBean.java
  
  Index: TestBean.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/test/org/apache/struts/test/TestBean.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TestBean.java	2000/09/07 01:38:37	1.2
  +++ TestBean.java	2001/01/08 00:17:43	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-struts/src/test/org/apache/struts/test/TestBean.java,v 1.2
2000/09/07 01:38:37 craigmcc Exp $
  - * $Revision: 1.2 $
  - * $Date: 2000/09/07 01:38:37 $
  + * $Header: /home/cvs/jakarta-struts/src/test/org/apache/struts/test/TestBean.java,v 1.3
2001/01/08 00:17:43 craigmcc Exp $
  + * $Revision: 1.3 $
  + * $Date: 2001/01/08 00:17:43 $
    *
    * ====================================================================
    *
  @@ -63,14 +63,19 @@
   package org.apache.struts.test;
   
   
  +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.2 $ $Date: 2000/09/07 01:38:37 $
  + * @version $Revision: 1.3 $ $Date: 2001/01/08 00:17:43 $
    */
   
  -public class TestBean {
  +public class TestBean extends ActionForm {
   
   
       // ------------------------------------------------------------- Properties
  @@ -228,6 +233,21 @@
   
       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;
  +        if (nested != null)
  +            nested.reset(mapping, request);
  +
       }
   
   
  
  
  
  1.1                  jakarta-struts/src/test/org/apache/struts/test/HtmlSettersAction.java
  
  Index: HtmlSettersAction.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-struts/src/test/org/apache/struts/test/HtmlSettersAction.java,v
1.1 2001/01/08 00:17:43 craigmcc Exp $
   * $Revision: 1.1 $
   * $Date: 2001/01/08 00:17:43 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 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", "Tomcat", 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.test;
  
  
  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/01/08 00:17:43 $
   */
  
  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("html-setters"));
  
      }
  
  
  }
  
  
  
  1.3       +5 -0      jakarta-struts/web/test/index.jsp
  
  Index: index.jsp
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/web/test/index.jsp,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- index.jsp	2000/09/07 01:36:36	1.2
  +++ index.jsp	2001/01/08 00:17:43	1.3
  @@ -19,6 +19,11 @@
   <li><a href="bean-write.jsp">&lt;struts-bean:write&gt;</a></li>
   </ul>
   
  +<h3>HTML Tags</h3>
  +<ul>
  +<li><a href="html-setters.jsp">Property Setters</a></li>
  +</ul>
  +
   <h3>LOGIC Tags</h3>
   <ul>
   <li><a href="logic-compare.jsp">Comparison Tags</a></li>
  
  
  
  1.1                  jakarta-struts/web/test/html-setters.jsp
  
  Index: html-setters.jsp
  ===================================================================
  <%@ page language="java"%>
  <%@ 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" %>
  <html:html>
  <head>
  <title>Test struts-html Property Setters</title>
  </head>
  <body bgcolor="white">
  
  <div align="center">
  <h1>Test struts-html Property Setters</h1>
  </div>
  
  <jsp:useBean id="setold" scope="session"
            class="org.apache.struts.test.TestBean"/>
  
  Whatever changes you make to properties should be reflected when the page
  is redisplayed.  Submit the form to update, or go back to the
  <a href="index.jsp">index.jsp</a> page.
  
  <html:form action="html-setters.do">
  <table border="0" width="100%">
  
    <tr>
      <th align="right">booleanProperty</th>
      <td align="left">
        <html:checkbox property="booleanProperty"/>
      </td>
    </tr>
  
    <tr>
      <th align="right">doubleProperty</th>
      <td align="left">
        <html:text property="doubleProperty" size="32"/>
      </td>
    </tr>
  
    <tr>
      <th align="right">floatProperty</th>
      <td align="left">
        <html:text property="floatProperty" size="32"/>
      </td>
    </tr>
  
    <tr>
      <th align="right">intProperty</th>
      <td align="left">
        <html:text property="intProperty" size="32"/>
      </td>
    </tr>
  
    <tr>
      <th align="right">longProperty</th>
      <td align="left">
        <html:text property="longProperty" size="32"/>
      </td>
    </tr>
  
    <tr>
      <th align="right">stringProperty</th>
      <td align="left">
        <html:text property="stringProperty" size="32"/>
      </td>
    </tr>
  
    <tr>
      <td align="right">
        <html:submit>Save</html:submit>
      </td>
      <td align="left">
        <html:reset>Reset</html:reset>
        <html:cancel>Cancel</html:cancel>
      </td>
    </tr>
  
  </table>
  
  </html:form>
  
  
  </html:html>
  
  
  
  1.2       +42 -0     jakarta-struts/web/test/WEB-INF/web.xml
  
  Index: web.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/web/test/WEB-INF/web.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- web.xml	2000/09/05 21:28:05	1.1
  +++ web.xml	2001/01/08 00:17:44	1.2
  @@ -7,16 +7,58 @@
   <web-app>
   
   
  +  <!-- Action Servlet Configuration -->
  +  <servlet>
  +    <servlet-name>action</servlet-name>
  +    <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
  +    <init-param>
  +      <param-name>config</param-name>
  +      <param-value>/WEB-INF/struts-config.xml</param-value>
  +    </init-param>
  +    <init-param>
  +      <param-name>debug</param-name>
  +      <param-value>2</param-value>
  +    </init-param>
  +    <init-param>
  +      <param-name>detail</param-name>
  +      <param-value>2</param-value>
  +    </init-param>
  +    <init-param>
  +      <param-name>validate</param-name>
  +      <param-value>true</param-value>
  +    </init-param>
  +    <load-on-startup>2</load-on-startup>
  +  </servlet>
  +
  +
  +  <!-- Action Servlet Mapping -->
  +  <servlet-mapping>
  +    <servlet-name>action</servlet-name>
  +    <url-pattern>*.do</url-pattern>
  +  </servlet-mapping>
  +
  +
     <!-- The Welcome File List -->
     <welcome-file-list>
       <welcome-file>index.jsp</welcome-file>
       <welcome-file>index.html</welcome-file>
     </welcome-file-list>
   
  +
     <!-- Struts Tag Library Descriptors -->
     <taglib>
       <taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
       <taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
  +  </taglib>
  +
  +  <taglib>
  +    <taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
  +    <taglib-location>/WEB-INF/struts-html.tld</taglib-location>
  +  </taglib>
  +
  +  <taglib>
  +    <taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri>
  +    <taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
     </taglib>
   
   
  
  
  
  1.1                  jakarta-struts/web/test/WEB-INF/struts-config.xml
  
  Index: struts-config.xml
  ===================================================================
  <?xml version="1.0" encoding="ISO-8859-1" ?>
  
  <!DOCTYPE struts-config PUBLIC
            "-//Apache Software Foundation//DTD Struts Configuration 1.0//EN"
            "http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd">
  
  <struts-config>
  
    <form-beans>
      <form-bean name="setnew"
                 type="org.apache.struts.test.TestBean"/>
    </form-beans>
  
    <global-forwards>
      <forward   name="index"                path="/index.jsp"/>
      <forward   name="html-setters"         path="/html-setters.jsp"/>
    </global-forwards>
  
    <action-mappings>
      <action    path="/html-setters"
                 type="org.apache.struts.test.HtmlSettersAction"
                 name="setnew"
                scope="session"
             validate="false"/>
    </action-mappings>
  
  </struts-config>
  
  
  

Mime
View raw message