Hi,

While normally the id can be anything you want, in the case of indexing
you are correct that it must be the same as the property.

The 'index out of bounds' is one of those classic problems with indexed
properties since the list that holds the objects must be pre-initialized
to hold them. If you search the archive you'll find a variety of
solutions, one being using a hidden field and the size of the list to
initialize in the reset method. The cooler (dare I say preferred? sure,
except I haven't tried it) solution was posted a couple times by Aaron
Bates which initializes on the fly.

-john

-----Original Message-----
From: Sandeep Takhar [mailto:[EMAIL PROTECTED]
Sent: Tuesday, June 10, 2003 11:59 AM
To: Struts Users Mailing List
Subject: RE: <logic:iterate> and <html:text indexed="true"/>


of course -I'm being stupid about the session scoped
beans,

however I haven't looked at the code and I don't know
how the "indexed" property works with the "iterate"
tag and I cannot extrapolate at the current moment
either about what the code might look like.  What I
mean to say is: I don't know if indexed="true" works
for anything other than forms.  Should I guess, maybe
you know.

Are you sure you can name the "id" anything you want? 
It didn't seem to work for me until I named it the
same as the property for whatever reason.  Do you have
a working sample?  I suppose I should just try it.

Also: if you are using the nested:iterate, can you
include a jsp and have it used indexed="true" I
wonder?

sandeep


--- Mark Galbreath <[EMAIL PROTECTED]> wrote:
> Of course it works with session-scoped beans; that's
> what an
> ActionForn/DynaActionForm is by default.  second,
> "id" is complete arbitrary
> - you can call any page object anything you want.
> 
> Mark
> 
> -----Original Message-----
> From: Sandeep Takhar
> [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, June 10, 2003 2:41 PM
> To: Struts Users Mailing List
> Subject: Re: <logic:iterate> and <html:text
> indexed="true"/>
> 
> 
> my small understanding on how to use this is as
> follows:
> 
> <logic:iterate name="form_name"
> property="property_name" id="property_name">
> 
> <html:text property="some_property" indexed="true">
> 
> ok -- 
> 
> 1. form_name is the name of the form
> 2. property_name is the name of the property and for
> some reason the id="" also has to have the same name
> 3. indexed="true" indicates that property is coming
> from what we are iterating over.
> 4. I have only got this to work with forms.
> 
> So I don't know if it works for session scoped beans
> and it means that when you submit it will populate
> the
> bean.
> 
> sandeep
> --- Nadja Senoucci <[EMAIL PROTECTED]> wrote:
> > Hello again,
> > 
> > I am currently testing around with the above named
> > tags (in order to get
> > around my earlier discribed problem sooner or
> later)
> > and I don't think I
> > quite understand what happens when you set
> > indexed=true for text fields.
> > 
> > I have this little bit of code in my .jsp:
> > 
> > <logic:present name="cntarr">
> > <bean:define name="cntarr" scope="session"
> > id="cntarr"
> > type="java.util.Collection"/>
> > <logic:iterate id="element" name="cntarr" >
> > <tr bgcolor="#FFFFFF">
> > <td colspan="2"><html:text property="searchfield" 
> > indexed="true"/></td> <td colspan="2"><html:text 
> > property="searchparam" indexed="true"/></td>
> > </tr>
> > </logic:iterate>
> > </logic:present>
> > 
> > And it seems that this results in the following
> bit
> > of HTML:
> > 
> > <tr bgcolor="#FFFFFF">
> > <td colspan="2"><input type="text"
> >
>
name="org.apache.struts.taglib.html.BEAN[0].searchfield"
> > value=""></td>
> > <td colspan="2"><input type="text"
> >
>
name="org.apache.struts.taglib.html.BEAN[0].searchparam"
> > value=""></td>
> > </tr>
> > 
> > Why is it saying
> "org.apache.struts.taglib.html.BEAN[0].searchfield"?
> > I
> > would have thought it would be
> > "element[0].searchfield... And what do I need
> >  to do in my form bean to create set-methods for
> > this? Meaning: What does
> > Struts expect to find in my form bean if I am
> using
> > an indexed field as
> > shown above?
> > 
> > At the moment, I keep getting an "index out of
> bounds"-exception which 
> > is quite natural, I think, since there is no array
> that
> > could be set with
> > something like this
> >
> "org.apache.struts.taglib.html.BEAN[0].searchfield".
> > So
> > I know, I am using these tags wrong. I just can't
> > find out how to use them
> > correctly...
> > 
> > Greetings,
> > Nadja
> > 
> > 
> > 
> >
>
---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> > For additional commands, e-mail:
> > [EMAIL PROTECTED]
> > 
> 
> 
> __________________________________
> Do you Yahoo!?
> Yahoo! Calendar - Free online calendar with sync to
> Outlook(TM).
> http://calendar.yahoo.com
> 
>
---------------------------------------------------------------------
> 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]
> 


__________________________________
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com

---------------------------------------------------------------------
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