public class OrderEntryForm extends ActionForm { /** * list of line items. */ private Collection lineItems ; /** * next withdraw from line item. */ private String nextWithdrawalDate ; /** * instantiates an empty collection of line items. */ public OrderEntryForm() { lineItems = new ArrayList() ; } /** * sets line items. * * @param c collection of line items. */ public void setLineItems(Collection c) { lineItems.addAll(c) ; } /** * returns line items. * * @return lineItems line items. */ public Collection getLineItems() { return lineItems ; } /** * add one line item to order entry form. * * @param o line item. */ public void addLineItem(OrderEntryLineItemForm o) { lineItems.add(o) ; } /** * I have to initialize the form otherwise got IndexOutOfBoundsException. I also need to reset markedForRemoval. * * @param mapping action mapping, no use. * @param request request to find the numLineItems in session. */ public void reset(ActionMapping mapping, HttpServletRequest request) { Iterator iterator = getOrder(......) ; while (iterator.hasNext()) { ((OrderEntryLineItemForm) iterator.next()).setMarkedForRemoval(Boolean.FALSE) ; } }
} Regards, PQ "This Guy Thinks He Knows Everything" "This Guy Thinks He Knows What He Is Doing" -----Original Message----- From: Greg Bearth [mailto:[EMAIL PROTECTED]] Sent: December 31, 2002 1:36 PM To: 'Struts Users Mailing List' Subject: RE: Updating collections of information I'm not sure I understand how I can override reset to solve this issue. Can you elaborate? Do I have to create an empty collection or something? To be clear, this is not the situation where checkboxes must be initialized to false in the reset method. I've already fallen for that one. My issue could simply be a collection of three beans which have String property values "A", "B", "C" respectively (of course in real life the size of the collection is not predetermined and the bean would have more properties). These values are displayed using the logic:iterate tag and the html:text tag (sample, untested code below). My form bean would have getBeanCollection() and setBeanCollection(Collection c) methods. Each bean in the collection has a getString() and setString(String s) methods. Assuming the user changes the three values to "D", "E", "F", how should my action class retrieve the new values? I'd like to call getBeanCollection() on the form bean and have it return a collection of three beans in which the getString method returns "D", "E", "F" respectively, but so far getBeanCollection() returns null. <logic:iterate name="selectedBean" id="element" property="beanCollection" type="xxx.yyy.ElementBean"> <tr> <td align="left"><html:text name="element" property="string"/></td> </tr> </logic:iterate> I appreciate your time and patience. -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Tuesday, December 31, 2002 10:20 AM To: [EMAIL PROTECTED] Subject: RE: Updating collections of information This is a classic question. You have to override reset in your form to correctly populate all the elements. Regards, PQ "This Guy Thinks He Knows Everything" "This Guy Thinks He Knows What He Is Doing" -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>