James
Can u give me some suggestion on the approach I should take, I was able
to at least come to this stage after 2 weeks of struggle. Now I have
some idea as how these tags work, if u can provide me  alternate
approach it would be great.

Thanks
>>> [EMAIL PROTECTED] 06/11/03 05:16PM >>>
I don't recommend doing it this way, but the problem seems to be with
your
last select tag.
The previous ones had an index, the last on does not.  This won't work,
as
you know.

--
James Mitchell
Software Developer/Struts Evangelist
http://www.struts-atlanta.org


----- Original Message ----- 
From: "Sashi Ravipati" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, June 11, 2003 8:29 AM
Subject: Re: How can I do this


> I am trying to build my table from the values I have in my arary.
>
> My JSp page code looks like this
>
> <TABLE id="mytable">
>     <logic:present property="firstName" name="addRateForm">
>           <logic:iterate id="element" name="addRateForm"
> property="firstName"  indexId="i" >
>           <tr>
>               <% int j = ((Integer)
> pageContext.getAttribute("i")).intValue(); %>
>            <td><html:text name="addRateForm"
> property="<%=\"firstName[\"+j+\"]\"%>" />
>             <bean:write name="addRateForm"
> property="<%=\"firstName[\"+j+\"]\"%>" />
>             <html:hidden property="firstName" value="a" />
>             </td>
>             <td><html:select  property="<%=\"sex[\"+j+\"]\"%>" >
>                 <html:option value="">&nbsp;</html:option>
>                <html:option value="Male" >Male</html:option>
>                <html:option value="Female" >Female</html:option>
>               </html:select>
>            </td>
>           </tr>
>          </logic:iterate>
>     </logic:present>
>     <tr>
>            <td><html:text  property="firstName" value="" /></td>
>            <td><html:select  property="sex">
>                 <html:option value="">&nbsp;</html:option>
>                <html:option value="Male" >Male</html:option>
>                <html:option value="Female" >Female</html:option>
>               </html:select>
>            </td>
>       </tr>
> </TABLE>
>
> Here my table is dynamic, I start with one empty row when the page
loads
> first, then I keep adding rows to the table and when I submit, (Lets
say
> b'cas of some validation errors I want to display the page again, now
I
> need to build the table where I am using the Logic:iterate to loop
thru
> my firstName array).
>
> My Action Form(addRateForm.java) Liiks like this
>
>    private String[] FirstName=null;
>    private String[] sex=null;
> public String[] getFirstName(){
>     return this.FirstName;
>   }
>
>  public void setFirstName(String[] newName){
>     FirstName = newName;
>     // setRow();
>   }
>   public String[] getSex(){
>     return sex;
>   }
>
>   public void setSex(String[] newSex){
>     sex = newSex;
>
>   }
>
> It all woks fine when I am doing the first time
>
> Say I added three rows and submitted, upon validation failure the page
> comes back with three rows of data and a blank row.
>
> This is the source after it builds the page
>
> <TABLE id="mytable">
>
>           <tr>
>
>            <td><input type="text" name="firstName[0]" value="Sashi ">
>             </td>
>             <td><select name="sex[0]"><option value="">&nbsp;</option>
>                <option value="Male" selected="selected">Male</option>
>                <option value="Female">Female</option></select>
>            </td>
>           </tr>
>
>           <tr>
>
>            <td><input type="text" name="firstName[1]" value="Sushma">
>             </td>
>             <td><select name="sex[1]"><option value="">&nbsp;</option>
>                <option value="Male">Male</option>
>                <option value="Female"
> selected="selected">Female</option></select>
>            </td>
>           </tr>
>
>
>     <tr>
>            <td><input type="text" name="firstName" value=""></td>
>            <td><select name="sex"><option value="">&nbsp;</option>
>                <option value="Male" >Male</option>
>                <option value="Female"
> selected="selected">Female</option></select>
>            </td>
>       </tr>
> </TABLE>
>
> Now when I make some changes and resubmit
>
> I get Null Pointer Exception
>
> java.lang.NullPointerException
>
> void
>
org.apache.commons.beanutils.PropertyUtils.setIndexedProperty(java.lang.Obje
ct,
> java.lang.String, int, java.lang.Object)
> PropertyUtils.java:1328........
>
> Let me know if I have to provide more info
>
> Also I used indexed="true" but it did not work so I tried to do the
way
> I showed above.
>
> Thanks
>
> >>> [EMAIL PROTECTED] 06/11/03 11:15AM >>>
> Can you explain what it is you are trying to do?  (in a broader scope)
>
> Have you looked at or used indexed fields before?
>
>
> --
> James Mitchell
> Software Developer/Struts Evangelist
> http://www.struts-atlanta.org
>
>
> ----- Original Message -----
> From: "Sashi Ravipati" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Wednesday, June 11, 2003 10:41 AM
> Subject: How can I do this
>
>
> I am reading the values from an array, when I build my table I use
> <html:text name="addRateForm" property="<%=\"firstName[\"+j+\"]\"%>"
/>
> the above tag converts to
> <input type="text" name="firstName[1]" value="b">
>
> Now I also want to build a hidden value along with the text box as
shown
> below
>
> <input type=hidden value="b" >
>
> I tried to to this which does not work
> <html:hidden property="firstName" value='<bean:write
name="addRateForm"
> property="<%=\"firstName[\"+j+\"]\"%>" />' />
>
> How can I achieve this
>
> Thanks
>
>
>
> ---------------------------------------------------------------------
> 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