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.
<s:property value="fooMap[#item.fooId]"/> 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<String, String> 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. > > > <s:select key="item.fooId" list="fooMap" /> > > > 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. > > > <s:iterator value="itemList" id="item"> <tr> > <td><s:property value="#item.name"/></td> > <td><s:property value="#item.fooId"/></td> </tr> </s:iterator> > > 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 > > > <s:iterator value="itemList" id="item"> <tr> > <td><s:property value="#item.name"/></td> > <td><s:property value="fooMap['%{#item.fooId}']"/></td> > </tr> > </s:iterator> > > > Alas to no avail so far. > It's no problem to retrieve the "fooMap" values by providing > a static index, for example > > > <s:iterator value="itemList" id="item"> > <tr> > <td><s:property value="#item.name"/></td> > <td><s:property value="fooMap['ID1']"/></td> > </tr> > </s:iterator> > > > 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]