Hi,

In my JSP I get an Vector with VehicleTO-objects (which was set into the
request
from an action). Now I want to Submit the generated form to another action
with
an associated ActionForm (VehicleForm). The VehicleForm has an indexed
property
(locationScheduleEntry) of type ArrayList.
locationScheduleEntry holds references to very simple Bean-Objects with
just two attributes (vehicleId and habitationStart).
In my form, the checkbox and textfield have to be indexed.

First I did it with a little trick and set the id of the VehicleTO to the
name of
of the indexed attribute in the VehicleForm:

-------SNIP----------
<logic:iterate name="vehicles" id="locationScheduleEntry" type="VehicleTO">
  <tr>
    <td><bean:write name="locationScheduleEntry"
property="vehiclemaker"/></td>
    <td><bean:write name="locationScheduleEntry"
property="vehicleModel"/></td>
     <% String
vehicleId=Integer.toString(locationScheduleEntry.getVehicleId());%>
    <td><html:checkbox name="locationScheduleEntry" property="vehicleId"
value="<%= vehicleId %>" indexed="true"/></td>
    <td><html:text name="locationScheduleEntry" property="habitationStart"
indexed="true"/></td>   
    <tr>  
  </logic:iterate>
-------END SNIP----------


The result was exactly what I want and the locationScheduleEntry in the
VehicleForm
was filled proper after submitting the form:
-------SNIP----------
    <tr>
    <td>VW</td>
    <td>Golf</td>
    <td><input type="checkbox" name="locationScheduleEntry[2].vehicleId"
value="106" checked="checked"></td>
    <td><input type="text" name="locationScheduleEntry[2].habitationStart"
value=""></td>  
    <tr>  
-------END SNIP----------


But now how can I do this without the "trick", if I got 2 or more beans
(VehicleForm and vehicles)?
The problem is, that the indexed Properties have to be indexed in the JSP
(for example with [0])
although the ArrayList from the VehicleForm is empty anyway and just needed
for submitting the
page and not for creating the content of the page.

<bean:define id="vehicleSubmit" name="vehicleForm" type="VehicleForm"/>
<logic:iterate name="vehicles" id="vehicle" type="VehicleTO">
  <tr>
    <td><bean:write name="vehicle" property="vehiclemaker"/></td>
    <td><bean:write name="vehicle" property="vehicleModel"/></td>
    <% String vehicleId=Integer.toString(vehicle.getVehicleId());%>
    <td>
    <html:checkbox name="vehicleSubmit"
property="locationScheduleEntry[0].vehicleId" value="<%= vehicleId %>"
indexed="true"/></td>   
    </td>
    <td>
    <html:text name="vehicleSubmit"
property="locationScheduleEntry[0].habitationStart" indexed="true"/>
    </td>
  </tr>  
  </logic:iterate>


Now the result looks like this:
<td>
<input type="checkbox"
name="vehicleSubmit[0].locationScheduleEntry[0].vehicleId" value="102"></td>

</td>


I hope you can give me some hints, how to solve this problem.

Thanks
Oliver


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

Reply via email to