You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Danielle Boukovska <bo...@yahoo.co.uk> on 2004/09/30 08:33:32 UTC
Setting values of nested collection
Hi all
I have a problem with setting the values on a hierarchy of nested
properties.
I have an ActionForm which has a property A of type HashMap. A is keyed
on
Strings, and each value of A is a Collection (ArrayList). This
collection
contains objects of type B.
I am trying to iterate through the keys A, and for each key, iterate
through
the corresponding value (which is an ArrayList of B objects), i.e. I am
trying to do 2 levels of iteration. The I want to display a property of
B
and let the user change it. I am able to display the properties of
object B
on the screen. However, for some reason the <nested:text> tag doesn't
work -
the textbox is there, but the input does not populate the form.
The following is what I am trying to do.
<nested:iterate id="idForA" property="A">
<nested:iterate name="idForA" property="value"> <!--this should access
collection of B objects -->
<nested:text property="foo"> <!--allow user to enter a
property of B -->
</nested>
</nested>
</nested>
The problem is that when I enter a new value for foo, nothing happens;
the
value of the nested property is not set. Is it possible to iterate through a HashMap, and let the user update its values?
I am quite new to Struts, and have spent a lot of time trying to get
this to
work, but no luck. Any help will be appreciated!
Thanks
Danielle
---------------------------------
ALL-NEW Yahoo! Messenger - all new features - even more fun!
---------------------------------
ALL-NEW Yahoo! Messenger - all new features - even more fun!
Re: Setting values of nested collection
Posted by Adam Hardy <ah...@cyberspaceroad.com>.
Hi Danielle,
are you sure you instantiated the appropriate hierarchy for struts to
save the form properties into on submit? You can build it yourself, keep
it in the session or use LazyBeans (not sure about the last one - might
be called LazyNested or similar).
Adam
On 09/30/2004 07:33 AM Danielle Boukovska wrote:
> Hi all
> I have a problem with setting the values on a hierarchy of nested
> properties.
> I have an ActionForm which has a property A of type HashMap. A is keyed
> on
> Strings, and each value of A is a Collection (ArrayList). This
> collection
> contains objects of type B.
> I am trying to iterate through the keys A, and for each key, iterate
> through
> the corresponding value (which is an ArrayList of B objects), i.e. I am
> trying to do 2 levels of iteration. The I want to display a property of
> B
> and let the user change it. I am able to display the properties of
> object B
> on the screen. However, for some reason the <nested:text> tag doesn't
> work -
> the textbox is there, but the input does not populate the form.
> The following is what I am trying to do.
> <nested:iterate id="idForA" property="A">
> <nested:iterate name="idForA" property="value"> <!--this should access
> collection of B objects -->
> <nested:text property="foo"> <!--allow user to enter a
> property of B -->
> </nested>
> </nested>
> </nested>
> The problem is that when I enter a new value for foo, nothing happens;
> the
> value of the nested property is not set. Is it possible to iterate through a HashMap, and let the user update its values?
> I am quite new to Struts, and have spent a lot of time trying to get
> this to
> work, but no luck. Any help will be appreciated!
> Thanks
> Danielle
--
struts 1.2 + tomcat 5.0.19 + java 1.4.2
Linux 2.4.20 Debian
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org