users
[Top] [All Lists]

RE: [cinjug-users] Struts DynaValidatorForm and collections

To: <users@xxxxxxxxxx>
Subject: RE: [cinjug-users] Struts DynaValidatorForm and collections
From: "Taylor, William J." <Bill.Taylor@xxxxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 7 Apr 2005 16:59:55 -0500
Delivered-to: mailing list users@cinjug.org
Mailing-list: contact users-help@cinjug.org; run by ezmlm
Thread-index: AcU7sO4YADwzESurQF+SPAGLfTLefQACnK/A
Thread-topic: [cinjug-users] Struts DynaValidatorForm and collections
Two things:

1) Do you get an error when you try doing this or is the class field
just not populating?

2) Are you trying to re-populated the array after the form has been
submitted? If this is the case, is the use of the hidden fields to
serialize the values on the page to "remember" them when the form is
submitted?
        
        So what you expect would be:

<input type="hidden" name="purchaseOrder.purchaseOrderLines[0].poNumber"
value="00000"/>
<input type="hidden" name="purchaseOrder.purchaseOrderLines[1].poNumber"
value="00001"/>
<input type="hidden" name="purchaseOrder.purchaseOrderLines[2].poNumber"
value="00002"/>

After the form is submitted these values would then repopulate the
purchaseOrderLines array?

I agree I don't think the session scope would help.


bt

-----Original Message-----
From: bill.manuel@xxxxxxxxxx [mailto:bill.manuel@xxxxxxxxxx] 
Sent: Thursday, April 07, 2005 4:32 PM
To: users@xxxxxxxxxx
Subject: [cinjug-users] Struts DynaValidatorForm and collections





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


---------
You may unsubscribe from this mailing list
by sending a blank email addressed to:
users-unsubscribe@xxxxxxxxxx

--
Find additional help by sending a blank email
addressed to:
users-help@xxxxxxxxxx


<Prev in Thread] Current Thread [Next in Thread>
  • RE: [cinjug-users] Struts DynaValidatorForm and collections, Taylor, William J. <=