I have run into this before as well.  My solution was just to include a
property on the form itself with the name set on the jsp that in turn
sets the property at the correct level instead of holding the property
on the form.  Just need to use javabeans naming convention so your
method is called when struts tries to repopulate the form.

Hope that makes sense.

Regards...djsuarez

-----Original Message-----
From: Muhammad Momin Rashid [mailto:[EMAIL PROTECTED] 
Sent: Thursday, August 26, 2004 4:48 AM
To: [EMAIL PROTECTED]
Subject: nested collections and index

Hello,

I have a collection of beans, and within the bean I have another
collection 
of beans (e.g. collection of Forms, when each form contains a collection
of 
FormFields).

Now in my JSP I am trying to iterate through the two nested collections 
(which works fine at this point).  When I access the fields of the
nested 
collection (formField) in my JSP they get displayed as desired too. 
However, the updates to the desired field are not being submitted.  The
HTML 
code generated by JSP contains references to formField[index].field (for
the 
nested bean), whereas, in my opinion it should generate something like 
forms[formIndex].formField[formFieldIndex].field.  Any ideas on how to 
accomplish this?

The reason behind all this is that the correct bean in the nested
collection 
should get updated when the person presses the submit button.  I have
tried 
this for a non-nested collection and the generated HTML works as
desired, 
but in case of nested collections, the beans do not get updated.  I
believe 
this has something to do with the generated HTML.  Perhaps there is some

additional tags I need to define somewhere, I have gone through the
nested 
tag library, but so far no success.

The code snippit from JSP is pasted at the end for your reference,
incase 
you need to look at it.  Thanks for your time and effort.

Regards,
Muhammad Momin Rashid.

<nested:iterate id="forms" name="FormCodeGenValidation" property="forms"

indexId="indexForm">
<tr>
<td><nested:write name="forms" property="formName"/></td>
<td><nested:write name="forms" property="packageForm"/></td>
<nested:present name="forms" property="formFields">

<table width="100%" cellpadding="0" cellspacing"0" border="0" 
id="TableFormFields">
<tr>
<td width="1%">&nbsp;</td>
<td>Field Name</td>
<td>Type</td>
<td>Required</td>
<td>Recursive</td>
</tr>

<nested:iterate id="formFields" name="forms" property="formFields"
indexId="indexFormField" type="VoFormField">
<tr>
<nested:nest property="forms">
<td width="1%">&nbsp;</td>
<td width="1%"><nested:write name="formFields" property="name"/></td>
<td width="1%" nowrap="true"><nested:write name="formFields" 
property="type"/></td>
<td><nested:checkbox name="formFields" property="required" 
indexed="true"/></td>
<td><nested:checkbox name="formFields" property="recursive" 
indexed="true"/></td>
</nested:nest>
</tr>
</nested:iterate>
</table>
</nested:present>
</tr>

</nested:iterate> 







---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to