Matt,
Try this instead:

DynaActionForm taxRatesForm = new DynaActionForm();
com.ntso.rsg.bus.tax.TaxRateBean[] taxRates = new
com.ntso.rsg.bus.tax.TaxRateBean[allTaxRates.length];

// allTaxRates is the array that holds my data bean

for(int i=0; i < allTaxRates.length; i++) {
    // this is the set I am using, from the Struts API:
    //set(java.lang.String name, int index, java.lang.Object value)
    //          Set the value of an indexed property with the specified
name.
    taxRatesForm.set("taxRates", taxRates);
}
    ... set all the other form properties
HttpSession session = request.getSession();
.
.
.

// advancedTaxRatesCurrentForm is the name of the form bean in struts-config
session.setAttribute("advancedTaxRatesCurrentForm", taxRatesForm);


Just to get this straight on what you want to do...
You want to have a DynaForm with an indexed property that contains a complex
datatype (ie a POitem). The # of items is dynamic.

-Richard


-----Original Message-----
From: Matt Bathje [mailto:[EMAIL PROTECTED] 
Sent: Thursday, November 20, 2003 1:50 PM
To: Struts Users Mailing List
Subject: Re: dynamically sized form


OK, This gets me a step closer - I never understood that last paragraph
completely, "The actual...." always got me :)

Anyway, here is what I have in my preloader now:

DynaActionForm taxRatesForm = new DynaActionForm();

// allTaxRates is the array that holds my data bean
for(int i=0; i < allTaxRates.length; i++) {
    // this is the set I am using, from the Struts API:
    //set(java.lang.String name, int index, java.lang.Object value)
    //          Set the value of an indexed property with the specified
name.
    taxRatesForm.set("ID", i, allTaxRates[i].getID());
    ... set all the other form properties
}
HttpSession session = request.getSession();

// advancedTaxRatesCurrentForm is the name of the form bean in struts-config
session.setAttribute("advancedTaxRatesCurrentForm", taxRatesForm);

Which is giving me the error:

java.lang.NullPointerException: No indexed value for 'ID[0]'   (if you need
the
entire stack trace let me know)

I think I may be using the wrong DynaActionForm.set method, or I
misunderstand the parameters to it or something.

Just for good measure, here is my form bean out of struts-config again:
<form-bean name="advancedTaxRatesCurrentForm"
                    type="org.apache.struts.action.DynaActionForm">
    <form-property name="taxRates" type="com.ntso.rsg.bus.tax.TaxRateBean[]"
/>
</form-bean>


Thanks,
Matt Bathje





----- Original Message ----- 
From: "Yee, Richard K,,DMDCWEST" <[EMAIL PROTECTED]>
To: "'Struts Users Mailing List'" <[EMAIL PROTECTED]>
Sent: Thursday, November 20, 2003 2:58 PM
Subject: RE: dynamically sized form


> Matt,
> In the previous email, I wrote, "You will need to dynamically create 
> the array of TaxRateBean and put it in session scope in order to 
> create the submission fields in your form. (See the last paragraph of 
> article #2)." I should have said that according to the article, you 
> prepopulate the
array
> in the form and put the form in session scope.
>
> -Richard
>


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

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

Reply via email to