On Fri, 14 Jan 2005 23:20:47 -0800, Oleg <[EMAIL PROTECTED]> wrote:
> Hi, ok I am trying to get my Dynamic List-Backed form to work, no
> luck, here is what I have so far.
>
> ActionForm with a List in it:
>
> public ArrayList getFields() {
> return fields;
> }
>
> public void setFields(ArrayList fields) {
> this.fields = fields;
> }
>
> Now, a field itslelf is a bean:
>
> public class FormField {
> private String label;
> private String name;
> private String value;
> private String type;
> private java.util.ArrayList props;
> private boolean required;
> .......................
> getter and setters here
> }
>
> There is an Action that gets the info from the database and populates
> into the ActionForm, no problem. Now Jsp page has something like this:
>
> <c:forEach items="${formActionForm.fields}" var="field">
> <tr>
> <td><html:text property="label" name="field"/></td>
> <td>
> <html:select property="type" name="field">
> <html:optionsCollection name="definitionFields"/>
> </html:select>
> </td>
> ///// and so on for all the properties
> </tr>
> </c:forEach>
>
Try something like this;
<logic:iterate name="formActionForm" property="fields" indexId="index"
id="field">
<tr>
<td>
<html:text property='<%="fields["+index.intValue()+"]"%>'/>
</td>
<td>
<html:select property='<%=fields["+index.intValue()+"]%>'>
<html:optionsCollection name="definitionFields"/>
</html:select>
</td>
/// similarly for other fields
</tr>
</logic:iterate>
The trick is to start from the form level and adjusting the property
accordingly.
for more info: http://struts.apache.org/faqs/indexedprops.html
> So my question is, how do I make it so when this values are changed
> and submitted they are changed in the ActionForm ?? IS there a way to
> have that happen automatically like with a normal actionform or I have
> to do it programatically?
>
> I am really stuck here!!!
>
> Oleg
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]