You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Lynn Stevens <ly...@hotmail.com> on 2004/08/23 02:55:35 UTC

setting a collection in my form bean usin iterate or forEach

I was wondering if someone could help me out with this question:

I know that I can use the logic:iterate tag to loop over an existing 
collection
in my form bean.  However, I want to do the opposite.  I want to make
n number of html:textfields and then when the user hits submit, I want to 
have
the information pulled from those n textfields and used to populate a String 
array
or ArrayList or some ordered collection.  If I put a String[] or ArrayList 
in my
DynaActionForm, this does not seem to work.  I have tried to prepopulate
the String[] or ArrayList with n number of empty Strings and this
still does not work.  I am wondering if in fact it might not be possible to 
automatically
do this.  Maybe struts will not pull items from inside an iterate or forEach 
tag
and populate a list.  I need to dynamically lay out the textfields, so I 
won't know in
advance how many I am placing on that page.  This is why I need to put them
within an iterate of forEach tag...

Does anyone know if this is possible?  Its driving me mad!

Thanks in advance,

Lynn



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: setting a collection in my form bean usin iterate or forEach

Posted by Rick Reumann <st...@reumann.net>.
Lynn Stevens wrote:

> If I put a String[] or 
> ArrayList in my
> DynaActionForm, this does not seem to work.   

<snip>

> Does anyone know if this is possible?  Its driving me mad!

Sure it'll work. Be more specific of how you are setting stuff up (paste 
the dyna/action form definition and the form code. Also, as someone else 
asked, what 'isn't work' - are you getting errors?


-- 
Rick

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: setting a collection in my form bean usin iterate or forEach

Posted by Kishore Senji <ks...@gmail.com>.
> or ArrayList or some ordered collection.  If I put a String[] or ArrayList
> in my
> DynaActionForm, this does not seem to work.  I have tried to prepopulate

Does it throw any exception? The important thing while iterating over
a collection and setting the indexed properties, you have to get the
"property" attribute right.

Take a look at http://struts.apache.org/faqs/indexedprops.html

Thanks,
Kishore Senji.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: setting a collection in my form bean usin iterate or forEach

Posted by Shinobu Kawai <sh...@ieee.org>.
Hi Lynn,

> and populate a list.  I need to dynamically lay out the textfields, so I 
> won't know in
> advance how many I am placing on that page.  This is why I need to put them
> within an iterate of forEach tag...
> 
> Does anyone know if this is possible?  Its driving me mad!
I have heard that Map-backed ActionForms works in those cases.
    http://struts.apache.org/userGuide/building_controller.html#map_action_form_classes

Best regards,
-- Shinobu Kawai

--
Shinobu Kawai <shinobu@ieee.org, shinobu@computer.org>




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org