You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by cr...@locus.apache.org on 2000/09/24 01:19:38 UTC

cvs commit: jakarta-struts/web/test bean-write.jsp

craigmcc    00/09/23 16:19:37

  Modified:    src/share/org/apache/struts/util BeanUtils.java
                        PropertyUtils.java
               web/test bean-write.jsp
  Log:
  Back out the change of syntax for nested and indexed properties that
  mistakenly got checked in.
  
  The delimiters remain "." for nesting and "[]" for indexing, since there
  are workarounds to the potential problems caused by the fact that these
  delimiters are significant in JavaScript.
  
  Revision  Changes    Path
  1.13      +6 -8      jakarta-struts/src/share/org/apache/struts/util/BeanUtils.java
  
  Index: BeanUtils.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/util/BeanUtils.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- BeanUtils.java	2000/09/23 22:51:47	1.12
  +++ BeanUtils.java	2000/09/23 23:19:33	1.13
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/util/BeanUtils.java,v 1.12 2000/09/23 22:51:47 craigmcc Exp $
  - * $Revision: 1.12 $
  - * $Date: 2000/09/23 22:51:47 $
  + * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/util/BeanUtils.java,v 1.13 2000/09/23 23:19:33 craigmcc Exp $
  + * $Revision: 1.13 $
  + * $Date: 2000/09/23 23:19:33 $
    *
    * ====================================================================
    *
  @@ -84,7 +84,7 @@
    * @author Craig R. McClanahan
    * @author Ralph Schaer
    * @author Chris Audley
  - * @version $Revision: 1.12 $ $Date: 2000/09/23 22:51:47 $
  + * @version $Revision: 1.13 $ $Date: 2000/09/23 23:19:33 $
    */
   
   public final class BeanUtils {
  @@ -357,10 +357,6 @@
        * property, as a String.  The index is specified by being appended
        * to the property name in square brackets.  If the specified index
        * is out of range, <code>null</code> is returned.
  -     * <p>
  -     * <strong>WARNING</strong> - Use of the "square brackets" syntax
  -     * for indexed references has been deprecated in favor of the new
  -     * approach using the PropertyUtils.INDEXED_DELIM delimiter
        *
        * @param bean Bean whose property is to be extracted
        * @param name name of the property to be extracted, plus a literal
  @@ -378,11 +374,13 @@
   	       NoSuchMethodException {
   
           // @deprecated Convert the deprecated syntax to the new format
  +        /*
   	int left = name.lastIndexOf("[");
   	int right = name.lastIndexOf("]");
           if ((left >= 0) && (right > left))
               name = name.substring(0, left) + PropertyUtils.INDEXED_DELIM +
                   name.substring(left + 1, right);
  +        */
   
   	// Parse the property name and subscript expression
           int delim = PropertyUtils.INDEXED_DELIM;
  
  
  
  1.4       +22 -13    jakarta-struts/src/share/org/apache/struts/util/PropertyUtils.java
  
  Index: PropertyUtils.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/util/PropertyUtils.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- PropertyUtils.java	2000/09/23 22:51:47	1.3
  +++ PropertyUtils.java	2000/09/23 23:19:33	1.4
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/util/PropertyUtils.java,v 1.3 2000/09/23 22:51:47 craigmcc Exp $
  - * $Revision: 1.3 $
  - * $Date: 2000/09/23 22:51:47 $
  + * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/util/PropertyUtils.java,v 1.4 2000/09/23 23:19:33 craigmcc Exp $
  + * $Revision: 1.4 $
  + * $Date: 2000/09/23 23:19:33 $
    *
    * ====================================================================
    *
  @@ -99,25 +99,25 @@
    *     will have a getter method named <code>getXyz()</code> or (for boolean
    *     properties only) <code>isXyz()</code>, and a setter method named
    *     <code>setXyz()</code>.</li>
  - * <li><strong>Nested (<code>name1_name2_name3</code>)</strong> The first
  + * <li><strong>Nested (<code>name1.name2.name3</code>)</strong> The first
    *     name element is used to select a property getter, as for simple
    *     references above.  The object returned for this property is then
    *     consulted, using the same approach, for a property getter for a
    *     property named <code>name2</code>, and so on.  The property value that
    *     is ultimately retrieved or modified is the one identified by the
    *     last name element.</li>
  - * <li><strong>Indexed (<code>name$index</code>)</strong> - The underlying
  + * <li><strong>Indexed (<code>name[index]</code>)</strong> - The underlying
    *     property value is assumed to be an array, or this JavaBean is assumed
    *     to have indexed property getter and setter methods.  The appropriate
    *     (zero-relative) entry in the array is selected.</li>
  - * <li><strong>Combined (<code>name1_name2$index_name3</strong> - Various
  + * <li><strong>Combined (<code>name1.name2[index].name3</strong> - Various
    *     forms combining nested and indexed references are also supported.</li>
    * </ul>
    *
    * @author Craig R. McClanahan
    * @author Ralph Schaer
    * @author Chris Audley
  - * @version $Revision: 1.3 $ $Date: 2000/09/23 22:51:47 $
  + * @version $Revision: 1.4 $ $Date: 2000/09/23 23:19:33 $
    */
   
   public final class PropertyUtils {
  @@ -130,13 +130,20 @@
        * The delimiter that preceeds the zero-relative subscript for an
        * indexed reference.
        */
  -    public static final char INDEXED_DELIM = '$';
  +    public static final char INDEXED_DELIM = '[';
   
   
       /**
  +     * The delimiter that follows the zero-relative subscript for an
  +     * indexed reference.
  +     */
  +    public static final char INDEXED_DELIM2 = ']';
  +
  +
  +    /**
        * The delimiter that separates the components of a nested reference.
        */
  -    public static final char NESTED_DELIM = '_';
  +    public static final char NESTED_DELIM = '.';
   
   
       // ------------------------------------------------------- Static Variables
  @@ -211,12 +218,13 @@
   
   	// Identify the index of the requested individual property
           int delim = name.indexOf(INDEXED_DELIM);
  -        if (delim < 0)
  +        int delim2 = name.indexOf(INDEXED_DELIM2);
  +        if ((delim < 0) || (delim2 <= delim))
   	    throw new IllegalArgumentException("Invalid indexed property '" +
   					       name + "'");
   	int index = -1;
   	try {
  -	    String subscript = name.substring(delim + 1);
  +	    String subscript = name.substring(delim + 1, delim2);
   	    index = Integer.parseInt(subscript);
   	} catch (NumberFormatException e) {
   	    throw new IllegalArgumentException("Invalid indexed property '" +
  @@ -591,12 +599,13 @@
   
   	// Identify the index of the requested individual property
   	int delim = name.indexOf(INDEXED_DELIM);
  -        if (delim < 0)
  +        int delim2 = name.indexOf(INDEXED_DELIM2);
  +        if ((delim < 0) || (delim2 <= delim))
   	    throw new IllegalArgumentException("Invalid indexed property '" +
   					       name + "'");
   	int index = -1;
   	try {
  -	    String subscript = name.substring(delim + 1);
  +	    String subscript = name.substring(delim + 1, delim2);
   	    index = Integer.parseInt(subscript);
   	} catch (NumberFormatException e) {
   	    throw new IllegalArgumentException("Invalid indexed property '" +
  
  
  
  1.2       +6 -6      jakarta-struts/web/test/bean-write.jsp
  
  Index: bean-write.jsp
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/web/test/bean-write.jsp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- bean-write.jsp	2000/09/05 21:28:05	1.1
  +++ bean-write.jsp	2000/09/23 23:19:36	1.2
  @@ -114,8 +114,8 @@
   <% for (int index = 0; index < 5; index++) { %>
     <tr>
       <td><%= index * 10 %></td>
  -    <td><bean:write name="test3" property='<%= "intArray[" + index + "]"%>'/></td>
  -    <td><bean:write name="test3" property='<%= "intIndexed[" + index + "]"%>'/></td>
  +    <td><bean:write name="test3" property='<%= "intArray[" + index + "]" %>'/></td>
  +    <td><bean:write name="test3" property='<%= "intIndexed[" + index + "]" %>'/></td>
     </tr>
   <% } %>
   </table>
  @@ -134,8 +134,8 @@
   <% for (int index = 0; index < 5; index++) { %>
     <tr>
       <td><%= "String " + index %></td>
  -    <td><bean:write name="test4" property='<%= "stringArray[" + index + "]"%>'/></td>
  -    <td><bean:write name="test4" property='<%= "stringIndexed[" + index + "]"%>'/></td>
  +    <td><bean:write name="test4" property='<%= "stringArray[" + index + "]" %>'/></td>
  +    <td><bean:write name="test4" property='<%= "stringIndexed[" + index + "]" %>'/></td>
     </tr>
   <% } %>
   </table>
  @@ -196,8 +196,8 @@
   <% for (int index = 0; index < 5; index++) { %>
     <tr>
       <td><%= index * 10 %></td>
  -    <td><bean:write name="test6" property='<%= "nested.intArray[" + index + "]"%>'/></td>
  -    <td><bean:write name="test6" property='<%= "nested.intIndexed[" + index + "]"%>'/></td>
  +    <td><bean:write name="test6" property='<%= "nested.intArray[" + index + "]" %>'/></td>
  +    <td><bean:write name="test6" property='<%= "nested.intIndexed[" + index + "]" %>'/></td>
     </tr>
   <% } %>
   </table>