How does your orderform bean look? What are the method signatures for the items property?

Thanks,
Mishkin.

Chandan Kulkarni wrote:

  I have this working now... Here's how I got this working.... I'm including my BeanUtils.java.Here's how my jsp looks (the <form:text> does not work as expected...I had to use the input tag...) 
<TABLE WIDTH=100% border=1>
<TR>
<TH> Item Name </th>
<TH> Quantity   </TH>
</TR> <% int count=0; %>
<logic:iterate id="orderlist" name="orderform"  property="items" length="2">
 <tr>
    <TD>
        <input TYPE="TEXT" name="<%= "items[" + count + "].itemName" %>" value="<%= ((OrderItem)orderlist).getItemName() %>"  />
    </td>
 <TD>
        <input TYPE="TEXT" name="<%= "items[" + count++ + "].quantity" %>" value="<%= ((OrderItem)orderlist).getQuantity() %>"  />
  </td>

  </TR>
</logic:iterate>
</TABLE>

The name is the nested and indexed name. The value field needs to be explicitly set to get the value from the bean. The changes I made to BeanUtils.java is.... I commented out this code inpublic static void populate(Object bean, String prefix, String suffix, HttpServletRequest request)     /* CK:
            int subscript = stripped.lastIndexOf("[");
            if (subscript >= 0)  // Remove subscript expression
            stripped = stripped.substring(0, subscript);
        CK:
     */
 This keeps the indexed part of the name And then in      public static void populate(Object bean, Hashtable properties)Added this code
 
     // Check to see if the name is nested or indexed - then use PropertyUtils.setProperty
     int indexed = name.lastIndexOf("[");
     int nested = name.lastIndexOf(".");
            if ((indexed >= 0) || (nested >= 0)) {
  try {
      PropertyUtils.setProperty( bean, name, Array.get(value, 0));
  }
  catch( java.lang.NoSuchMethodException e ) {
  }
        continue;
     } 
To handle the nested and indexed names by calling PropertyUtils.setProperty... Good luck,      -Chandan Kulkarni.

S/MIME Cryptographic Signature

Reply via email to