struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bill Siggelkow <bills...@bellsouth.net>
Subject Re: newbie question on indexed properties
Date Fri, 09 Jul 2004 14:25:05 GMT
Davide,

Maybe I am doing something wrong but I have had problems getting indexed 
=true to work for arrays on the form -- it works correctly for arrays of 
a nested property of form.

For example, if I were to use what you suggested I get something like:
  <br/><input type="text" 
name="org.apache.struts.taglib.html.BEAN[0].answer" 
value="[Ljava.lang.String;@487c5f">

          <br/><input type="text" 
name="org.apache.struts.taglib.html.BEAN[1].answer" 
value="[Ljava.lang.String;@487c5f">

          <br/><input type="text" 
name="org.apache.struts.taglib.html.BEAN[2].answer" 
value="[Ljava.lang.String;@487c5f">

When what I want is:

<br/><input type="text" name="answer[0]" value="foo">

<br/><input type="text" name="answer[1]" value="bar">

<br/><input type="text" name="answer[2]" value="baz">

I am doing something wrong?

Davide Gurgone wrote:

> Bill Siggelkow wrote:
> 
>> You will need to add indexed getters and setters --
>>
>> public String getAnswer(int index);
>> public String setAnswer(int index, String value);
>>
>>   <logic:iterate name="questionForm" property="answers"
>>                id="answer" indexId="ctr">
>>     <br/><html:text property=’<%="answer["+ctr+"]"%>’/>
>>   </logic:iterate>
>>
> Better :)
>   [CUT]
>     <html:text property="answers" indexed="true" />
>   [CUT]
> it render a property named property[0], property[1], etc


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message