You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by James Turner <tu...@blackbear.com> on 2003/07/14 12:32:57 UTC

[ARTICLE] Succeeding with Struts Pt 2: Indexed Properties of Beans

Just an FYI that the second article in my "Succeeding with Struts"
series is now up on Gamelan, at:

http://www.developer.com/java/ejb/article.php/2233591

This month, I covered using indexed arrays of beans to do master/detail
records in forms.  Next month, I'll be diving into the Validator
Framework.

James Turner
turner@blackbear.com

Senior Editor
LinuxWorld Magazine

Track Chair, Strategic Open Source
2003 Fall COMDEX

Author: 
    MySQL & JSP Web Applications
    Struts Kick Start
    JavaServer Faces Kick Start 
 



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


RE: [ARTICLE] Succeeding with Struts Pt 2: Indexed Properties of Beans

Posted by James Turner <tu...@blackbear.com>.
> From: Craig R. McClanahan [mailto:craigmcc@apache.org] 
> 
> The iterated object has "key" and "value" properties to give 
> you access to either the key or the value with a nested expression.
> 

Right, but there's no way to use them with the indexed="true" flag of
the html tags.  You still end up having to do some convoluted field name
generation using EL or <%=.

James



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


RE: [ARTICLE] Succeeding with Struts Pt 2: Indexed Properties of Beans

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Tue, 15 Jul 2003, James Turner wrote:

> Date: Tue, 15 Jul 2003 08:59:30 -0400
> From: James Turner <tu...@blackbear.com>
> Reply-To: Struts Users Mailing List <st...@jakarta.apache.org>
> To: 'Rick Reumann' <r...@reumann.net>,
>      'Struts Users Mailing List' <st...@jakarta.apache.org>
> Subject: RE: [ARTICLE] Succeeding with Struts Pt 2: Indexed Properties of
>     Beans
>
> Rick,
>    I haven't found a good way to do this without a lot of gross "<%="
> hacking, specifically because the Struts and JSTL interators give you a
> handle to the index of the interated object, not the key.

The iterated object has "key" and "value" properties to give you access to
either the key or the value with a nested expression.

>  But frankly,
> I don't see a huge need to do this.  Since the ActionForm is a separate
> object (or should be) from the backend business object, you can map in
> and out between an array and a Map during form setup and Action
> processing.
>
> James

Craig

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


RE: [ARTICLE] Succeeding with Struts Pt 2: Indexed Properties of Beans

Posted by James Turner <tu...@blackbear.com>.
Rick,
   I haven't found a good way to do this without a lot of gross "<%="
hacking, specifically because the Struts and JSTL interators give you a
handle to the index of the interated object, not the key.  But frankly,
I don't see a huge need to do this.  Since the ActionForm is a separate
object (or should be) from the backend business object, you can map in
and out between an array and a Map during form setup and Action
processing.  

James 

> -----Original Message-----
> From: Rick Reumann [mailto:r@reumann.net] 
> Sent: Tuesday, July 15, 2003 8:34 AM
> To: Struts Users Mailing List
> Subject: Re: [ARTICLE] Succeeding with Struts Pt 2: Indexed 
> Properties of Beans
> 
> 
> On Mon, Jul 14,'03 (06:32 AM GMT-0400), James wrote: 
> 
>  
> > http://www.developer.com/java/ejb/article.php/2233591
> > 
> > This month, I covered using indexed arrays of beans to do 
> > master/detail records in forms.
> 
> Thanks James, excellent example! One thing I would now still 
> like to see.. could you alter the code so that rather than 
> providing an array of POLine beans you used a Map of POLine 
> beans? So that you'd iterate over the Map and when you 
> submitted the form each value in the Map (a POLine
> bean) would be reflected accordingly (maybe each key happened 
> to be partNumbr)? I haven't found a good way to do this using 
> JSTL and Struts-el tags so if you have an example or ideas 
> I'm all ears (or
> eyes?:)
> 
> Thanks.
> 
> -- 
> Rick
> 



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


Re: [ARTICLE] Succeeding with Struts Pt 2: Indexed Properties of Beans

Posted by Rick Reumann <r...@reumann.net>.
On Mon, Jul 14,'03 (06:32 AM GMT-0400), James wrote: 

 
> http://www.developer.com/java/ejb/article.php/2233591
> 
> This month, I covered using indexed arrays of beans to do
> master/detail records in forms.  

Thanks James, excellent example! One thing I would now still like to
see.. could you alter the code so that rather than providing an array of
POLine beans you used a Map of POLine beans? So that you'd iterate over
the Map and when you submitted the form each value in the Map (a POLine
bean) would be reflected accordingly (maybe each key happened to be
partNumbr)? I haven't found a good way to do this using JSTL and
Struts-el tags so if you have an example or ideas I'm all ears (or
eyes?:)

Thanks.

-- 
Rick

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