I'm having a problem with iterators and getting value updates. I've
searched the mailing list for hours but I can't seem to hit on a
solution. Perhaps I'm searching for the wrong thing. Any insights
would be helpful. It seems like it ought to be easy.
Let's say I have an object in my action called "report." And a
report object has certain fields (such as "title) and also has a Set
of "author" objects. And each author object has a "bio" String. I
want to display the report title and then each author's bio and allow
them to be changed via a web page. Something like this:
<s:textfield value="%{report.title} name="report.title"/>
<s:iterator value="report.authors">
<s:textarea value="%{bio}" name="bio" cols="40" rows="4"/>
</s:iterator>
This works fine for displaying the information from the calling
action: I see the report title and all of the bios for each author
associated with the report via my jsp output. No problem.
But, this does NOT work for getting changes made in the bio textarea
back into my object on post/submit to the next action.
Changes to the report.title textfield work fine. That works. It's
the "bio" textarea that I seem to have a problem with because (I
assume) it's embedded in the iterator tag. Simply putting "bio" in
the textarea's "name" obviously doesn't work. I've tried about 8 or
9 different things, but none work. I'm sure it's got to be simple,
but the solution eludes me. What should the textarea's "name" be to
get struts2 to update the specific report.author.bio String?
Thanks,
Kevin