Many thanks for the confirmation Dave. I'll convert my Hibernate mappings to List or Map.
I wonder why the Hibernate docs use Set and mention Set is the most commonly used Collection in mappings. I realize that is a discussion for another venue though. Thanks again. On Wed, Jun 22, 2011 at 3:53 PM, Justin Robbins <justinhrobb...@gmail.com> wrote: > Hi folks, > > I have a POJO which has a field of type java.util.Set that is > collection of domain objects. When I submit a form to my Action, all > the POJO fields are populated with values from the form except the > field which is the collection. I have no idea why this collection > isn't getting populated. Any advice on how to resolve this problem or > how to better troubleshoot it would be much appreciated. > > I'm posting some code excerpts below but please not that I posted > larger code excerpts for my example in a separate post StackOverflow. > I hope that's not considered a faux pas for cross posting but it > didn't seem these emails are a great place to copy and paste a bunch > of code. > > http://stackoverflow.com/questions/6443498/pojos-collection-not-populated-when-submitting-form > > I also have a second related question. My POJO's collection is a > java.util.Set. Does it matter to Struts 2 (or complicate things) that > I'm using a Set and not a List? Is it common to use a Set as a > collection field in a POJO used in Struts 2? The reason I'm using a > Set is that I'm using Hibernate for ORM and according to the > documentation a Set is the most common collection used association > based mappings in Hibernate. > > <s:textfield name="flashCard.links.url" key="label.flashcard.link" size="66" > /> > > I've also tried: > <s:textfield name="flashCard.links[0].url" key="label.flashcard.link" > size="66" /> > > From the Action class: > FlashCard flashCard = new FlashCard(); > > public FlashCard getFlashCard() { > return this.flashCard; > } > > public void setFlashCard(FlashCard flashCard) { > this.flashCard = flashCard; > } > > From the POJO: > private Set<Link> links = new HashSet<Link>(0); > > public Set<Link> getLinks() { > return this.links; > } > > public void setLinks(Set<Link> links) { > this.links = links; > } > > -- > Regards, > Justin Robbins > -- Regards, Justin Robbins 973.479.0448 justinhrobb...@gmail.com Learn more about me by viewing my professional profile on LinkedIn http://www.linkedin.com/in/justinhrobbins View my professional blog http://javadeveloperjournal.blogspot.com/ --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org