It is my understanding that for indexed properties to work, you need to
have an additional method:
public void setLocationList(int index, ChildForm form) {
this.locationList.set(index, form);
}
This is because the nested tags produce indexed elements in the form:
<input type="text" name="locationList[0]" value="" />
<input type="text" name="locationList[1]" value="" />
... etc.
The only way I got this to work was to populate the array with empty
forms, and then the setLocationList(int, form) replaced the empty ones
with the correct ones. As I said earlier, this seems silly to me and
their should be an easier way. I spent about a day on this trying all
kinds of different approaches, and this was the only one I could get to
work.
Matt
> -----Original Message-----
> From: Jarrett Grantham [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, January 19, 2003 2:45 PM
> To: Struts Developers List
> Subject: RE: Nested Struts ..Monkey Struts
>
>
> I tried that and I don't understand what is done in the reset
> method. You mentioned that you create a new ArrayList of the
> specified size(that I have done without problem); but when u
> mention populate it with empty child forms....I don't
> understand that. I don't see how we can populate this new
> array list with the child forms when the child forms are
> empty when the page is submitted. I have defined in my Form
> class the following:
>
> private List locationList = new ArrayList();
> public Object[] getLocationList()
> {
> return this.locationList.toArray();
> }
>
> public void setLocationList( Object[] anLocationArray)
> {
> this.locationList = new ArrayList();
> for( int each = 0; each < anLocationArray.length; each++ )
> {
> locationList.add( anLocationArray[each] );
> }
> }
>
> Now when I set a break point in the reset method of my
> Location Form and submit the form, the variable locationList is empty.
>
> Any ideas?
>
> jg
>
> Jarrett Grantham
> Razza Solutions
> 1149 Haleys Way Dr
> Buda, Tx 78610
> 512-797-8198
> www.razzasolutions.com
>
> -----Original Message-----
> From: Matt Raible [mailto:[EMAIL PROTECTED]]
> Sent: Saturday, January 18, 2003 6:37 PM
> To: 'Struts Developers List'
> Subject: RE: Nested Struts ..Monkey Struts
>
>
> I have been able to do this successfully - but only by
> setting a hidden variable that tells my ParentForm what size
> the ArrayList for the ChildForm is. Then in my reset method,
> I grab the hidden variable (indicating size) and create a new
> ArrayList of the specified size and populate it with empty
> child forms.
>
> It seems like quite a workaround - but it works!
>
> Matt
>
> > -----Original Message-----
> > From: James Nguyen [mailto:[EMAIL PROTECTED]]
> > Sent: Saturday, January 18, 2003 2:36 PM
> > To: Struts Developers List
> > Subject: Re: Nested Struts ..Monkey Struts
> >
> >
> > I've also experience this as well. If there's a clear
> explanation of
> > why this happens, please share. I have a hunch as to why, but I
> > don't know for
> > sure. It would be nice to not have to use the session scope just to
> > retrieve my form inputs when there's no need for it to be in
> > the session scope.
> >
> > I'm glad someone else experience this besides me. =)
> >
> > James Nguyen
> >
> > At 01:44 PM 1/17/2003 -0600, you wrote:
> > >I have been using Struts 1.0 for some time now and I was
> > wondering if
> > >anyone has ever run into this particular problem. I am
> nesting forms
> > >with nested tags(Monkey Struts add on )which works great for
> > displaying
> > >data using the scope of "request". I understand that nested
> > struts is
> > >now included in the latest version of Struts 1.1B3. I have
> > noticed that
> > >when I use a input field such as a text input box and then
> > submit the
> > >page that has nested forms on it; the nested forms do not
> > get rendered
> > >to my action class(form param in my perform method). Only
> > the top level
> > >Parent form is populated; any child forms( a array list in
> my parent
> > >form class) are not populated. If I change the scope to
> > session, then
> > >the child form's are populated in my Action class. The difference
> > >between Session and Request in this particular example puzzles me.
> > >
> > >
> > >Anyone seen anything like this?
> > >
> > >Thanks, Jarrett
> > >
> > >Jarrett Grantham
> > >Razza Solutions
> > >1149 Haleys Way Dr
> > >Buda, Tx 78610
> > >512-797-8198
> > >www.razzasolutions.com
> >
> >
> > James Nguyen
> > I/T Professional
> > 600 Anton Boulevard - Suite 360
> > Costa Mesa, California 92626
> >
> > "Cogito ergo sum"
> > -Rene Descartes
> >
> >
> > --
> > To unsubscribe, e-mail:
> > <mailto:struts-dev-> [EMAIL PROTECTED]>
> > For
> > additional commands,
> > e-mail: <mailto:[EMAIL PROTECTED]>
> >
>
>
>
> --
> To unsubscribe, e-mail:
> <mailto:struts-dev-> [EMAIL PROTECTED]>
> For
> additional commands,
> e-mail: <mailto:[EMAIL PROTECTED]>
>
>
>
> --
> To unsubscribe, e-mail:
> <mailto:struts-dev-> [EMAIL PROTECTED]>
> For
> additional commands,
> e-mail: <mailto:[EMAIL PROTECTED]>
>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>