This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Struts and the fly likes forms and collections Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "forms and collections" Watch "forms and collections" New topic

forms and collections

Alister Pate
Ranch Hand

Joined: Sep 13, 2002
Posts: 34
Hi Everyone.
I'm having a problem with trying to get my html:form to populate the collection in my actionform. Here is the code snippet:
<html:form action="/deleteAddress">
<html:hidden name="groupForm" property="groupID"/>
<logic:iterate name="addresses" id="address">
<td><bean:write name="address" property="phoneNumber"/> </td>
<td><bean:write name="address" property="name"/></td>
<html:checkbox name="address" property="delete"/></tr>
<html:hidden name="address" property="addressID"/>
The deal is that the form is being populated happily by large the address collection from my form bean (groupForm). But when I submit it, the collection is not being populated. The other fields in the form form are being populated as you might expect (eg the groupID is being populated), but the collection remains empty. How do I persuade struts to put the iterated items back into the collection? Is there some other way to do this sort of thing?
The basic aim is to get something like the inbox in hotmail, where you can select emails for deletion.
Any suggestions would help, I'm really tearing my hair out here.

Junilu Lacar

Joined: Feb 26, 2001
Posts: 4446

Use indexed property syntax. See for examples

Junilu - [How to Ask Questions] [How to Answer Questions]
Alister Pate
Ranch Hand

Joined: Sep 13, 2002
Posts: 34
Thanks for that.
It strikes me that there's a certain irony in an article on how to write struts based applications being served by php rather than java....
Alister Pate
Ranch Hand

Joined: Sep 13, 2002
Posts: 34
Actually, I was kinda hoping to find some way of doing it with collections rather than arrays...
Still, I'll give this a bash.
Alister Pate
Ranch Hand

Joined: Sep 13, 2002
Posts: 34
Actually, I found a really good link (After several hours of trying) which explained it very well. Here 'tis
And if you find, like I did, that you get errors saying something like "indexed not allowed by TLD", then you might want to consider updating your copy of struts (the tlds and the jar file) - it took me a little while to work that out.
I agree. Here's the link:
subject: forms and collections
Similar Threads
How to get results from indexed fields????
Passing parameters to an Action Form
Using checkbox/multibox to delete items from a list
validation of indexed properties