IMO a set is user-hostile unless you've defined an iterator with known sequence, otherwise the same page might return the same values in a different order. That's just confusing.
(And I've never actually used a set in Hibernate, always a list or a map.) I don't think collection syntax (square brackets, as you tried) or indexed notation (paren) would work, since there's no getAt type thing for a set. You may be able to create a custom type converter, but meh. Dave On Mon, Jun 27, 2011 at 10:15 AM, Justin Robbins <justinhrobb...@gmail.com> wrote: > Hi folks, > > Not possible to populate a java.util.Set from a form post in Struts 2? > A discussion on Stack Overflow concluded that you can't populate a > java.util.Set type Collection with a form post in Struts 2. Can you > guys confirm? > > Basically, I'm able to successfully iterate over a Set in a JSP to > display the Collection but when I post a form to the Action all the > POJO's fields get populated except the field that is of type > java.util.Set. > > For those that use Hibernate I'm guessing this would be a common issue > since Set is the most common collection mapping. > > http://stackoverflow.com/questions/6443498/pojos-collection-not-populated-when-submitting-form > > Many thanks for your input. > > > 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 > > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org