Sandeep,

Thank you for your response. I checked in mail archive and found several
suggestions. In particular I looked at this suggestion
http://www.mail-archive.com/[EMAIL PROTECTED]/msg72404.html
and realized that there is a slight problem with this code. For those who
would like to know how I got it working here it is:

Change the Code which says :

// THIS METHOD IS REQUIRED IF YOUR FORM IS OF REQUEST SCOPE.
public MyBean getIndexedBeans(int index) {

  while (this.myBeans.size() < index) 
    this.myBeans.add(new MyBean());

  return (MyBean) this.myBeans.get(index);
}

To this:

// THIS METHOD IS REQUIRED IF YOUR FORM IS OF REQUEST SCOPE.
public MyBean getIndexedBeans(int index) {

  while ((this.myBeans.size()-1) < index) 
    this.myBeans.add(new MyBean());

  return (MyBean) this.myBeans.get(index);
}

because size is not zero-based where as index is.

Thanks
Amit

-----Original Message-----
From: Sandeep Takhar [mailto:[EMAIL PROTECTED]
Sent: Monday, July 14, 2003 5:08 PM
To: Struts Users Mailing List
Subject: Re: Indexed form values


session scoped beans or request?

If request - then there have been numerous replies
about this FAQ which is that you have to initialize
all values less than or equal to the index that are
null.

i.e. getObject(int index)

sandeep

--- Amit Kirdatt <[EMAIL PROTECTED]> wrote:
> I have a struts form where I am doing the following:
> 
> <logic:present name="form1" property="arrayList1"
> scope="request">
>   <logic:iterate id="arrayValue1" name="form1"
> property="arrayList1">
>     <html:hidden name="arrayValue1" property="id1"
> indexed="true"/>
>     <html:hidden name="arrayValue1"
> property="exampleBean.stuffValue"
> indexed="true"/>
>     <html:hidden name="arrayValue1"
> property="exampleBean.exampleInfo.exId1"
> indexed="true"/>
>   </logic:iterate>
> </logic:present>
> 
> <logic:present name="form1" property="arrayList2"
> scope="request">
>   <logic:iterate id="arrayValue2" name="form1"
> property="arrayList2">
>     <html:hidden name="arrayValue2" property="id2"
> indexed="true"/>
>     <html:hidden name="arrayValue2"
> property="exampleBean1.stuffValue"
> indexed="true"/>
>     <html:hidden name="arrayValue2"
> property="exampleBean1.exampleInfo.exId1"
> indexed="true"/>
>   </logic:iterate>
> </logic:present>
> 
> I have to "carry" these hidden values thru 3 pages
> before inserting into the
> database, the first page is where these values get
> set. On the second page
> the values populate correctly, but on the second
> page the second "iterate"
> loop does not populate at all. After investigating I
> found that arrayList is
> not populating (size 0) from the second page to the
> third page, but the
> first "iterarte" loop works just fine thru all pages
> and inserts into the DB
> correctly. I have tried searching on the web and
> haven't found any answers.
> Can somebody please help!
> 
> Thanks,
> Amit
> 
> 
> This e-mail, including attachments, may include
> confidential and/or
> proprietary information, and may be used only by the
> person or entity to
> which it is addressed. If the reader of this e-mail
> is not the intended
> recipient or his or her authorized agent, the reader
> is hereby notified that
> any dissemination, distribution or copying of this
> e-mail is prohibited. If
> you have received this e-mail in error, please
> notify the sender by replying
> to this message and delete this e-mail immediately.
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
> 


__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

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


This e-mail, including attachments, may include confidential and/or
proprietary information, and may be used only by the person or entity to
which it is addressed. If the reader of this e-mail is not the intended
recipient or his or her authorized agent, the reader is hereby notified that
any dissemination, distribution or copying of this e-mail is prohibited. If
you have received this e-mail in error, please notify the sender by replying
to this message and delete this e-mail immediately.

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

Reply via email to