Atta, I was going to resize in the setter out of caution since I'm not familiar enough with when the getter and setter is called in Struts. You may be right that I don't have to do it in the setter. Thanks for validating my thoughts. It looks like it works.
Thanks, Dave -----Original Message----- From: atta-ur rehman [mailto:[EMAIL PROTECTED] Sent: Tuesday, July 06, 2004 3:33 PM To: Struts Users Mailing List Subject: Re: Submitting Indexed Properties and List Size/Resize Hello Dave, I think you're pretty close! I don't see why do you have to resize the list in the setter though? Here is what I've done and it works: public BlockEffort getBlock(int index) { while (blockEffortList.size() <= index) { blockEffortList.add(new BlockEffort()); } return (BlockEffort) blockEffortList.get(index); } public void setBlock(int index, BlockEffort block) { this.blockEffortList.add(index, block); } Now, maybe more struts-knowledgable can add something to my 2 c! ATTA ----- Original Message ----- From: "Ellingson, David" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, July 06, 2004 12:21 PM Subject: Submitting Indexed Properties and List Size/Resize > I wanted to verify whether I am understanding the best way to submit indexed > properties to an ActionForm. > > I was originally having problems with ArrayOutOfBoundsExceptions when > submitting the Form, and, after some research, it looks like the framework > is expecting the List to be prepopulated before it can be populated with the > Request parameters. While this can be done in the constructor, it seems the > best way is to dynamically resize the collection in both the get and set > index methods. For example, if a get() is called for index 10, and records > don't exist up to the 10th record, I can add the additional records up to > the 10th element. This works fine, but it seems a little awkward, so I > wasn't sure if I am missing something here. > > Is this the best way to submit indexed properties to an ActionForm? > > Thanks, > Dave > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]