You should set scope of the bean as session. 

> -----Original Message-----
> From: Joel [mailto:[EMAIL PROTECTED]
> Sent: Sunday, August 24, 2003 11:59 AM
> To: [EMAIL PROTECTED]
> Subject: DynaForm Beans and Indexed Text fields.
> 
> 
> I'm having a problem using Indexed text fields with DynaActionForms. I
> can make a jsp display my indexed text fields just fine using the
> <logic:iterate> and <html:text> custom tags. The problem is when I
> submit the form, there is a problem populating the DynaActionForm with
> my indexed text values. I'm wondering if the problem is the fact that
> the collection used is a java.util.List populated with by own custom
> beans, each bean containing three String fields with their own
> getters/setters. I'm wondering if I can use DynaActionForms in this
> instance. Below is a copy of my DynaActionForms Config, the jsp code
> that utilizes the form and the error message I get when the form is
> submitted. Any input would be of great help.
> 
> Thanks,
> 
> Joel.
> 
> 
> Here's my DynaActionForm Bean declaration in struts-config.xml:
> 
> <form-bean
> name="persistRateInfo"
> type="org.apache.struts.action.DynaActionForm">
> 
> <!-- Specify the dynamic properties of the form -->
> <form-property name="hazardInsRate" type="java.lang.String"/>
> <form-property name="dealOneTerm" type="java.lang.String"/>
> <form-property name="dealOneIR" type="java.lang.String"/>
> <form-property name="dealOnePercentageDown" type="java.lang.String"/>
> <form-property name="dealTwoTerm" type="java.lang.String"/>
> <form-property name="dealTwoIR" type="java.lang.String"/>
> <form-property name="dealTwoPercentageDown" type="java.lang.String"/>
> <form-property name="dealThreeTerm" type="java.lang.String"/>
> <form-property name="dealThreeIR" type="java.lang.String"/>
> <form-property name="dealThreePercentageDown"
type="java.lang.String"/>
> <form-property name="pmiRanges" type="java.util.List"/>
> </form-bean>
> 
> Here's the loop I use in the jsp that needs to display the values of
> pmiRanges. of the form bean:
> 
> <logic:iterate id="pmiRanges" name="persistRateInfo"
property="pmiRanges">
> <tr>
> <td style="font-family: sans; font-size: 12;" width="100">Low: </td>
> <td style="font-family: sans; font-size: 12;">
> <html:text name="pmiRanges" property="low" indexed="true" size="5"/>
> </td>
> 
> <td style="font-family: sans; font-size: 12;" width="100">High: </td>
> <td style="font-family: sans; font-size: 12;">
> <html:text name="pmiRanges" property="high" indexed="true" size="5"/>
> </td>
> 
> <td style="font-family: sans; font-size: 12;" width="100">Rate: </td>
> <td style="font-family: sans; font-size: 12;">
> <html:text name="pmiRanges" property="rate" indexed="true" size="5"/>
> </td>
> </tr>
> </logic:iterate>
> 
> Now I use a Struts Action to preload this form bean with values from a
> database. It does this fine. When the jsp is called for the first
time,
> it utilizes the form bean, and the List perfectly and displays the
> indexed text fields just like I want it to. here is an example row of
> rendered text fields:
> 
> <tr>
> <td style="font-family: sans; font-size: 12;" width="100">Low: </td>
> <td style="font-family: sans; font-size: 12;">
> <input type="text" name="pmiRanges[0].low" size="5" value="10.0">
> 
> </td>
> 
> <td style="font-family: sans; font-size: 12;" width="100">High: </td>
> <td style="font-family: sans; font-size: 12;">
> <input type="text" name="pmiRanges[0].high" size="5" value="15.0">
> </td>
> 
> <td style="font-family: sans; font-size: 12;" width="100">Rate: </td>
> <td style="font-family: sans; font-size: 12;">
> 
> <input type="text" name="pmiRanges[0].rate" size="5" value="5.7">
> </td>
> </tr>
> 
> The problem comes in when I try to submit the form to save the form
> values. It doesn't seem that the form bean can be populated with
> the indexed values. I get the follwoing Exception:
> 
> ?
> 
> java.lang.NullPointerException: No indexed value for 'pmiRanges[0]'
>       at
> org.apache.struts.action.DynaActionForm.get(DynaActionForm.java:293)
>       at
>
org.apache.commons.beanutils.PropertyUtils.getIndexedProperty(PropertyUt
il
> s.java:474)
>       at
>
org.apache.commons.beanutils.PropertyUtils.getIndexedProperty(PropertyUt
il
> s.java:428)
>       at
>
org.apache.commons.beanutils.PropertyUtils.getNestedProperty(PropertyUti
ls
> .java:770)
>       at
>
org.apache.commons.beanutils.PropertyUtils.getProperty(PropertyUtils.jav
a:
> 801)
>       at
> org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:881)
>       at
> org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:808)
> 
> 
> 
> ---------------------------------------------------------------------
> 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