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