Is there anyway to have a property in my ActionForm class be defined as follows:
private LabelValueBean[] myItems;
And be able to have struts automatically populate this collection when the form is submitted? If so, how do I go about storing those values in the form so they're seen and populated properly upon submission?
Well, a LabelValueBean has two string properties -- how would you automatically populate even a single instance, let alone an array?
Or are you suggesting that the form presents the user with a series of paired input fields, essentially "label1", "value1", "label2", "value2", etc?
If so, you could essentially do it by exposing an indexed property, "labelValueBeans" and then arranging to have your request parameters be named as such:
labelValueBeans[0].label labelValueBeans[0].value labelValueBeans[1].label labelValueBeans[1].value
I would do this using c:forEach and the struts-el tags, roughly like this:
<c:forEach begin="0" end="5" varStatus="status"> Label: <html:text property="labelValueBeans[${status.count}].label" /><br /> Value: <html:text property="labelValueBeans[${status.count}].value" /><br /> </c:forEach>
If you aren't using the EL, there are other ways to do this, but frankly, I never learned how to do them and I think it's cleaner with the JSTL.
Joe
-- -- Joe Germuska Vice President, Software Development JGSullivan Interactive, Inc. [EMAIL PROTECTED] 312/943-1600 x2488 (v) 312/943-9675 (f) [EMAIL PROTECTED] 312/404-3783 (m)
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]