Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

forms and collections

 
Alister Pate
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 7758
61
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use indexed property syntax. See http://www.developer.com/java/ejb/article.php/2233591 for examples
 
Alister Pate
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic