wood burning stoves 2.0*
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 Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "forms and collections" Watch "forms and collections" New topic
Author

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">
<tr>
<td><bean:write name="address" property="phoneNumber"/> </td>
<td><bean:write name="address" property="name"/></td>
<td>
<html:checkbox name="address" property="delete"/></tr>
<html:hidden name="address" property="addressID"/>
</logic:iterate>
...etcetera
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.

Alister
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 4419
    
    5

Use indexed property syntax. See http://www.developer.com/java/ejb/article.php/2233591 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
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
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
"http://www.mail-archive.com/struts-user@jakarta.apache.org/msg74986.html
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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: forms and collections
 
Similar Threads
How to get results from indexed fields????
validation of indexed properties
Passing parameters to an Action Form
Using checkbox/multibox to delete items from a list
HTML:OPTIONS