Thanks. I hope somebody knows the answer to the first question.

re: my iterate over String array question --- I've got half of a solution, 
i.e. to pre-populate the form by supplying the "value" attribute. The other 
half is producing HTML input text tags with "name" attributes aString[0], 
aString[1],... so the form bean will be populated on submit. I assume that I 
would do the exact same thing you suggested for the value tag in the property 
tag, i.e. 
<html:text indexed="true" name="aBean" property='<%="aString[" + GET_INDEX + 
"]"%>'   value= '<%="aString[" + GET_INDEX + "]"%>' />

So, the "property" and "value" attributes would have identical values ?

However, this seems wrong, because based on your document, my HTML name would 
evaluate to "aBean.[nn].aString[nn], rather than aString[nn]

Also, I still don't know where to get the index that I would put in GET_INDEX 
above ?  

Obviously I'm pretty lost here --- as I said, I can only find 
examples/discussions in the mailing archive with collections of beans, but 
nothing with collections of Strings, which is what I'm trying to do.

Thanks,
Charlie


> I have a feeling that both could be interpreted as correct, but we could
> use some other opinions on this.  I wrote the first one, so I'll update
> it if this discussion points out a better way to say this.
>
> On your quandary with iterating over a collection of String objects,
> instead of beans, it's useful to note that if the "value" attribute is
> present, that is used as the value, but the "name/property" pair is used
> as the request parameter name.  If the "value" attribute is missing, the
> value is taken from the "name/property" pair.  In this case, you should
> set the "value" attribute using an expression scriptlet (or an EL
> expression, using Struts-EL), and define an appropriate formbean setter
> method (based on the indexed name/property settings).
>
> -----Original Message-----
> From: Charlie Toohey [mailto:[EMAIL PROTECTED]]
> Sent: Friday, January 31, 2003 12:07 PM
> To: [EMAIL PROTECTED]
> Subject: html:text tag "indexed" attribute
>
> Two things regarding using the "indexed" attribute of the Struts
> html:text
> tag.
>
> First, there is a disagreement between the Struts FAQ on indexed
> properties
> and the Struts HTML tag docs.
>
> The Struts FAQ
> http://jakarta.apache.org/struts/faqs/indexedprops.html
> states that setting indexed="true" results HTML "name" attribute of
> "name[nn].property", where name is the name attribute of the html:text
> tag
>
> The Struts HTML tag docs
> http://jakarta.apache.org/struts/struts-html.html#text
> state that setting indexed="true" results in HTML "name" attribute of
> "id[34].propertyName", where id is an attibute in the logic:iterate tag.
>
> I'm sure there are many situations where the logic:iterate "id"
> attribute
> value is the same as the html:text "name" attribute, but not always.
> Does
> anyone know which or these docs is the correct one ?
>
>
> Second thing I'm confused about has to do with iterating over a
> collection of
> String objects using logic:iterate and the html:text "indexed" attribute
> set
> to true. I have scoured the mailing list archives and see plenty of
> discussion/examples about how to use these to iterate over a collection
> of
> beans --- the html:text tag would specify the desired property of the
> bean as
> the value of the "property" attribute. However, a String does not have
> properties, so I don't understand how to do it for a collection of
> Strings.
>
> e.g. using the Struts FAQ stringbean bean as an example, I believe the
> following would successfully iterate over the LabelValue objects in the
> stringbean's lvbeans array, using the value of the label property for
> the
> html text tag.
>
> <logic:iterate name="stringbean" property="lvbeans" id="labelValue">
>   <html:text name="labelValue" property="label" indexed="true" />
> </logic:iterate>
>
> resulting in HTML "name" attribute of labelValue[nn].label
>
>
> but, lets say I have an array of String objects (stringArray) instead of
> an
> array of beans, and tried the following:
>
> <logic:iterate name="stringbean" property="stringArray" id="aString">
>   <html:text name="aString" property="?????" indexed="true" />
> </logic:iterate>
>
> My goal is have this generate HTML text tags with "name" attribute of
> aString[0], aString[1], etc.
> Since a String does not have a property, what would be used for the
> property
> value ??
>
> Thanks for any help !
>
> - Charlie
>
>
>
> ---------------------------------------------------------------------
> 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]

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

Reply via email to