Hi,

I found that the easiest way to do this is to use LazyLists. (cf.
http://wiki.apache.org/struts/StrutsCatalogLazyList). You can then work just
as you
with fixed lists. An example:

in my jsp I have something like ...

<logic:iterate name="FgZuordnungForm" property="zuordAll" id="zuordAll">
<tr>
<td><html:text name="zuordAll" indexed="true" property="from" /></td>
<td><html:text name="zuordAll" indexed="true" property="to" "/></td>
</tr>
</logic:iterate>
<span Id="fgzList"></span>

(Note the indexed="true"). I have a javascript function that creates more
table rows
where the <span...> stands. These rows look just like the ones created by
the
html:text tag, except that the array-index is increased, i.e.
... myInput.setAttribute('name','zuordAll['+row_cnt+'].'+ 'from');

In the corresponding form, the List is simply declared as
private List zuordAll=ListUtils.lazyList(new ArrayList(),
new Factory() {
public Object create() { return new ZuordData();
}
});
plus the normal setter and getter. (ZuordData is just a bean with properties
from and to).

Thats all. You can pass in a List of size n, add a few rows using Javascript
and,
after submitting the form get out a List of size n+k.

Rather simple once one has figured it out.

Hope that helps,

Ulrich




On 11/6/05, Agnisys <[EMAIL PROTECTED]> wrote:
>
> Hi,
> In my application the user can add any number of input text fields to add
> properties to a form
> (implemented using Javascript). Is there a way to create an ActionForm
> that can get an array of
> property values from the JSP page, without knowing how many they are? How
> would such properties be
> specified in the config file?
> I don't see any way of getting all these properties in a JavaBean, since a
> bean requires that
> the property names and number be known statically.
> I looked at the LazyActionForm but I don't think that would help in this
> situation.
>
> Thanks,
> Anupam.
>
>
>
>
>
> __________________________________
> Start your day with Yahoo! - Make it your home page!
> http://www.yahoo.com/r/hs
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

Reply via email to