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 16:45:01 GMT
Rick Reumann wrote:

> Bill Siggelkow wrote:
> 
>> Okay -- now I am confused -- if I use your approach I get ...
>>
>> javax.servlet.ServletException: Cannot find bean esami in any scope
>>
>> I have to specify the name of the form as the value for the 'name' 
>> atrribute of logic:iterate
> 
> 
> Are you sure you have the iterate taking place inside of (below) 
> <html:form ... > (Been a while since I've used logic:iterate though. 
> Just use the JSTL forEach.. he he I'm telling you, you're the JSTL 
> master:).
> 

Yeah -- the logic:iterate is in the html:form -- though I don't think it 
really makes a difference -- the iterate tag knows nothing about being 
in a form. From my experience, using indexed="true" applies the index to 
the "name" specified for the html:text (or other html:) tag, not the 
"property" ... therefore, I can only used indexed="true" if I am setting 
  the property of a nested bean that is indexed. I can set the value if 
the indexed property is a simple type (e.g. a String).

So if I have an indexed property Foo that is a String array than I have 
to use scriptlet ...
   <logic:iterate name="MyForm" property="fooArray" id="foo" indexId="ctr">
     <br/><html:text property=’<%="foo["+ctr+"]"%>’/>
   </logic:iterate>

This will render
<br/><input type="text" name="foo[0]">
<br/><input type="text" name="foo[1]">
...

However, if the indexed property is itself a bean, say Foo with property 
  Bar, I can use indexed=true

   <logic:iterate name="MyForm" property="fooArray" id="foo">
     <br/><html:text name="foo" property="bar" indexed="true"/>
   </logic:iterate>

This will render
<br/><input type="text" name="foo[0].bar">
<br/><input type="text" name="foo[1].bar">

Bill


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


Mime
View raw message