Struts2: How to access indexed property (map) with dynamic index?

2008-09-25 Thread Keim, Markus
Hello all,
 
is it possible (and how) to access the values of an indexed property
(a map) with the Struts2 "property" tag by providing a dynamicaly
retrieved/calculated index?

In detail:
Let's assume that "fooMap" is a simple Map that's
provided by a Struts2 action. That map holds a unique key (ID)
and a description for a property of objects of the class "Item".
It serves as source for a "select" tag to set that property
when adding new items.





On the same (JSP) page I want to list all existing items, using
an "iterator" tag.
That's quite easy, as long as I output the "fooId" as a simple
property.



  


  


What I want to achive is to output the "fooDescription",
that is, the value that I would get by


fooMap.get(item.fooId);


I've played around with plenty variations of



  


  



Alas to no avail so far.
It's no problem to retrieve the "fooMap" values by providing
a static index, for example



  


  



will output the description to "ID1".
But how can I provide the dynamicaly retrieved index
from within the iterator?
Any insight on this would be highly appreciated. :)


Ciao,

Markus

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



AW: Struts2: How to access indexed property (map) with dynamic index?

2008-09-25 Thread Keim, Markus
Doh, I can't believe that I skipped that variation.
It's the (inner) single quotation marks that I'd never ommited
(since it's a string-index).
So, you're (almost) perfectly right.



does the job.
Thx, you made my day! 8)


-Ursprüngliche Nachricht-
Von: Musachy Barroso [mailto:[EMAIL PROTECTED] 
Gesendet: Donnerstag, 25. September 2008 16:06
An: Struts Users Mailing List
Betreff: Re: Struts2: How to access indexed property (map) with dynamic index?

try: #fooMap[#item.fooId]


On Thu, Sep 25, 2008 at 9:45 AM, Keim, Markus <[EMAIL PROTECTED]> wrote:

> Hello all,
>
> is it possible (and how) to access the values of an indexed property 
> (a map) with the Struts2 "property" tag by providing a dynamicaly 
> retrieved/calculated index?
>
> In detail:
> Let's assume that "fooMap" is a simple Map that's 
> provided by a Struts2 action. That map holds a unique key (ID) and a 
> description for a property of objects of the class "Item".
> It serves as source for a "select" tag to set that property when 
> adding new items.
>
>
> 
>
>
> On the same (JSP) page I want to list all existing items, using an 
> "iterator" tag.
> That's quite easy, as long as I output the "fooId" as a simple 
> property.
>
>
>   
>
>   
>
> What I want to achive is to output the "fooDescription", that is, the 
> value that I would get by
>
>
> fooMap.get(item.fooId);
>
>
> I've played around with plenty variations of
>
>
>   
>
>
>  
> 
>
>
> Alas to no avail so far.
> It's no problem to retrieve the "fooMap" values by providing
> a static index, for example
>
>
> 
>  
>
>
>  
> 
>
>
> will output the description to "ID1".
> But how can I provide the dynamicaly retrieved index
> from within the iterator?
> Any insight on this would be highly appreciated. :)
>
>
> Ciao,
>
> Markus
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

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