All,
I'm hoping I can find someone who has tried this before. I am trying
to use the DynaValidatorForm, which I have used before, but not in the same
manner.
Lets say I have a class PurchaseOrder with several properties. One of
those properties is an array of objects (PurchaseOrderLine).
PurchaseOrder:
properties: (all getters and setters are assumed)
private String poNumber;
.... a bunch of other properties
private PurchaseOrderLine[] purchaseOrderLines;
PurchaseOrderLine:
private String itemNumber;
... a bunch of other properties...
Struts config:
<form-bean name="purchaseOrderForm"
type="org.apache.struts.validator.DynaValidatorForm">
<form-property name="purchaseOrder" type="somepackage.PurchaseOrder">
</form-bean>
JSP: (assuming the action is mapped to my form)
<html:form action="/someAction" method="post">
<html:hidden property="purchaseOrder.poNumber"/>
<c:forEach items="${purchaseOrder.purchaseOrderLines}
var="poLine" varStatus="status">
<html:hidden name="poLine" property="itemNumber"/>
</c:forEarch>
</html:form>
Heres the problem (finally):
The part in the c:forEach loop works (sort of). It displays each element
in the array. The problem comes when I try posting to the server. The
lines in the html source look like this:
<input type="hidden" name="poLine[0].poNumber" value="000000"/>
I would expect it would only work if I get it to display like this:
<input type="hidden" name="purchaseOrder.purchaseOrderLines[0].poNumber"
value="00000"/>
I have tried several solutions to this with no success. One person
suggested setting the scope of the form bean on the action to "session"
scope instead of request. I haven't tried this yet, but I'm guessing it
won't work either. I will try it tonight, but If anyone has an example of
this working somewhere, I would name my first child after them. (Well,
maybe not)
If this just looks like gibberish to you, please ignore me.
Thanks in advance.
Bill Manuel
|